@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,69 +0,0 @@
1
- import React, { ErrorInfo } from 'react';
2
- import { AlertTriangle, RefreshCw } from 'lucide-react';
3
-
4
- interface Props {
5
- children: React.ReactNode;
6
- pluginName?: string;
7
- pluginId?: string;
8
- }
9
-
10
- interface State {
11
- hasError: boolean;
12
- error: Error | null;
13
- }
14
-
15
- export class PluginErrorBoundary extends React.Component<Props, State> {
16
- constructor(props: Props) {
17
- super(props);
18
- this.state = { hasError: false, error: null };
19
- }
20
-
21
- static getDerivedStateFromError(error: Error): State {
22
- // Update state so the next render will show the fallback UI.
23
- return { hasError: true, error };
24
- }
25
-
26
- componentDidCatch(error: Error, errorInfo: ErrorInfo) {
27
- // Here we could log the error to our telemetry service (e.g. OpenTelemetry / Kernel)
28
- console.error(`🚨 [Plugin Error Boundary] Plugin ${this.props.pluginName || this.props.pluginId || 'Unknown'} crashed:`, error, errorInfo);
29
- }
30
-
31
- resetBoundary = () => {
32
- this.setState({ hasError: false, error: null });
33
- };
34
-
35
- render() {
36
- if (this.state.hasError) {
37
- return (
38
- <div className="w-full h-full flex flex-col items-center justify-center p-6 bg-red-950/10 border border-red-500/20 rounded-xl m-2 backdrop-blur-xs relative overflow-hidden">
39
- <div className="absolute top-0 left-0 w-full h-1 bg-linear-to-r from-red-500/50 to-orange-500/50" />
40
- <AlertTriangle className="w-12 h-12 text-red-400 mb-4 opacity-80" />
41
- <h3 className="text-lg font-bold text-red-200 mb-2 text-center text-balance">
42
- Plugin Crashed
43
- </h3>
44
- <p className="text-sm text-red-300/70 text-center mb-6 max-w-sm">
45
- The plugin <span className="text-red-200 font-mono bg-red-900/40 px-1 py-0.5 rounded">{this.props.pluginName || this.props.pluginId || 'unknown'}</span> encountered an unexpected runtime error. The core OS remains stable.
46
- </p>
47
-
48
- {this.state.error && (
49
- <div className="w-full bg-surface-overlay p-3 rounded-lg border border-red-900/30 mb-6 overflow-auto max-h-24">
50
- <code className="text-xs text-red-400 font-mono whitespace-pre-wrap break-all">
51
- {this.state.error.toString()}
52
- </code>
53
- </div>
54
- )}
55
-
56
- <button
57
- onClick={this.resetBoundary}
58
- className="flex items-center gap-2 px-4 py-2 bg-red-500/10 hover:bg-red-500/20 active:bg-red-500/30 text-red-300 border border-red-500/30 rounded-lg transition-colors text-sm font-medium"
59
- >
60
- <RefreshCw className="w-4 h-4" />
61
- Reload Plugin
62
- </button>
63
- </div>
64
- );
65
- }
66
-
67
- return this.props.children;
68
- }
69
- }
@@ -1,114 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { kernel } from '@decido/kernel-bridge';
3
- import clsx from 'clsx';
4
- import { twMerge } from 'tailwind-merge';
5
-
6
- interface ServerDrivenNode {
7
- type: string;
8
- props?: Record<string, any>;
9
- children?: ServerDrivenNode[] | string;
10
- onAction?: {
11
- command: string;
12
- payload?: any;
13
- };
14
- }
15
-
16
- interface Props {
17
- uiSchema: string | ServerDrivenNode; // JSON Stringified or Object
18
- missionData?: any;
19
- tenantId: string;
20
- }
21
-
22
- const ALLOWED_ELEMENTS = ['div', 'span', 'p', 'button', 'input', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'a', 'ul', 'ol', 'li', 'section', 'article', 'aside', 'header', 'footer', 'nav', 'main', 'figure', 'figcaption', 'blockquote', 'hr', 'br', 'b', 'i', 'u', 's', 'em', 'strong', 'small', 'sub', 'sup', 'mark', 'del', 'ins', 'kbd', 'samp', 'var', 'code', 'pre', 'q', 'cite', 'dfn', 'abbr', 'time', 'address', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'wbr', 'table', 'caption', 'colgroup', 'col', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th'];
23
-
24
- const cn = (...classes: (string | undefined | null | false)[]) => twMerge(clsx(classes));
25
-
26
- export const SafeLiquidUI: React.FC<Props> = ({ uiSchema, missionData, tenantId }) => {
27
-
28
- const parsedSchema = useMemo<ServerDrivenNode | null>(() => {
29
- if (!uiSchema) return null;
30
- if (typeof uiSchema === 'object') return uiSchema;
31
- try {
32
- return JSON.parse(uiSchema);
33
- } catch (e) {
34
- console.error('[Server-Driven UI] Failed to parse schema:', e);
35
- return null;
36
- }
37
- }, [uiSchema]);
38
-
39
- const handleAction = async (command: string, payload: any) => {
40
- try {
41
- await kernel.execute(tenantId, command, { ...payload, __missionContext: missionData });
42
- } catch (error) {
43
- console.error('[Server-Driven UI] RPC Execution Failed:', error);
44
- kernel.injectEvent({
45
- type: 'system_alert',
46
- source: 'SafeLiquidUI',
47
- payload: { level: 'error', title: 'Action Failed', message: String(error) }
48
- });
49
- }
50
- };
51
-
52
- const renderNode = (node: ServerDrivenNode | string, index?: number): React.ReactNode => {
53
- if (typeof node === 'string') return node;
54
- if (!node || !node.type) return null;
55
-
56
- const elementType = ALLOWED_ELEMENTS.includes(node.type) ? node.type : 'div';
57
-
58
- // Sanitize and prepare props
59
- const elementProps: Record<string, any> = { ...node.props, key: index };
60
-
61
- // Merge secure Tailwind classes
62
- if (elementProps.className) {
63
- elementProps.className = cn(elementProps.className);
64
- }
65
-
66
- // Attach Kernel RPC Actions
67
- if (node.onAction && node.onAction.command) {
68
- const actionTarget = elementType === 'input' ? 'onChange' : 'onClick';
69
- elementProps[actionTarget] = (e: any) => {
70
- // Prevent default if it's a button/link
71
- if (e && typeof e.preventDefault === 'function') {
72
- e.preventDefault();
73
- e.stopPropagation();
74
- }
75
- const value = e?.target?.value;
76
- const dynamicPayload = value !== undefined ? { ...node.onAction?.payload, value } : node.onAction?.payload;
77
- handleAction(node.onAction!.command, dynamicPayload);
78
- };
79
- }
80
-
81
- // Render children recursively
82
- let renderedChildren: React.ReactNode = null;
83
- if (Array.isArray(node.children)) {
84
- renderedChildren = node.children.map((child, i) => renderNode(child, i));
85
- } else if (typeof node.children === 'string') {
86
- // Very basic templating substitution: {{ missionData.title }}
87
- renderedChildren = node.children.replace(/\{\{\s*([a-zA-Z0-9_.]+)\s*\}\}/g, (match, path) => {
88
- const keys = path.split('.');
89
- let val = { missionData };
90
- for (const key of keys) {
91
- if (val && typeof val === 'object' && key in val) val = (val as any)[key];
92
- else return match;
93
- }
94
- return String(val);
95
- });
96
- }
97
-
98
- return React.createElement(elementType, elementProps, renderedChildren);
99
- };
100
-
101
- if (!parsedSchema) {
102
- return (
103
- <div className="w-full h-full flex items-center justify-center bg-surface-primary/50 backdrop-blur border border-border-subtle rounded-xl p-8 text-text-muted font-mono text-xs">
104
- Waiting for Server-Driven UI Schema...
105
- </div>
106
- );
107
- }
108
-
109
- return (
110
- <div className="w-full h-full overflow-y-auto custom-scrollbar">
111
- {renderNode(parsedSchema)}
112
- </div>
113
- );
114
- };
@@ -1,92 +0,0 @@
1
- import React from 'react';
2
- import { X, ExternalLink, Minimize2, Maximize2 } from 'lucide-react';
3
- import { useShellStore } from '../store/engine';
4
- import { ShellPluginProvider } from '../core/PluginContext';
5
- import { PluginErrorBoundary } from './PluginErrorBoundary';
6
-
7
- export const TransientLayer: React.FC = () => {
8
- const transientOverlays = useShellStore((state) => state.transientOverlays);
9
- const widgets = useShellStore((state) => state.widgets);
10
- const closeTransientOverlay = useShellStore((state) => state.closeTransientOverlay);
11
-
12
- if (transientOverlays.length === 0) return null;
13
-
14
- return (
15
- <div className="fixed inset-0 z-100 pointer-events-none">
16
- {transientOverlays.map((overlay) => {
17
- const WidgetMeta = widgets.get(overlay.widgetId);
18
-
19
- if (!WidgetMeta) return null;
20
- const WidgetComponent = WidgetMeta.component;
21
-
22
- // Safe Zones (Morphological Clamping)
23
- const MARGIN = 16;
24
- const ACTIVITY_BAR_WIDTH_SAFE = 72; // w-14 (56px) + 16px de margen
25
-
26
- // Forzamos un máximo width y height para que la ventana nunca se apropie del 100%
27
- let width = overlay.position.width || 400;
28
- let height = overlay.position.height || 300;
29
-
30
- let x = overlay.position.x;
31
- let y = overlay.position.y;
32
-
33
- if (typeof window !== 'undefined') {
34
- // Safe Zone Limits
35
- const maxWidth = window.innerWidth - ACTIVITY_BAR_WIDTH_SAFE - MARGIN;
36
- const maxHeight = window.innerHeight - (MARGIN * 2);
37
-
38
- // Clamp Dimensions
39
- if (width > maxWidth) width = maxWidth;
40
- if (height > maxHeight) height = maxHeight;
41
-
42
- // Compute maximum coordinates considering the clamped dimensions
43
- const maxX = window.innerWidth - width - MARGIN;
44
- const maxY = window.innerHeight - height - MARGIN;
45
-
46
- // Clamp X (Ningún widget puede cruzar a la izquierda del ActivityBar)
47
- if (x < ACTIVITY_BAR_WIDTH_SAFE) x = ACTIVITY_BAR_WIDTH_SAFE;
48
- if (x > maxX) x = maxX;
49
-
50
- // Clamp Y
51
- if (y < MARGIN) y = MARGIN;
52
- if (y > maxY) y = maxY;
53
- }
54
-
55
- return (
56
- <div
57
- key={overlay.id}
58
- className="absolute shadow-2xl rounded-2xl overflow-hidden glass-panel border border-border-default pointer-events-auto animate-in fade-in zoom-in-95 duration-200"
59
- style={{
60
- left: x,
61
- top: y,
62
- width,
63
- height,
64
- }}
65
- >
66
- {/* Transient Header Controls */}
67
- <div className="flex justify-between items-center px-4 py-2 bg-surface-overlay border-b border-border-subtle backdrop-blur-md">
68
- <span className="text-xs font-semibold text-text-primary/70">{WidgetMeta.name}</span>
69
- <button
70
- onClick={() => closeTransientOverlay(overlay.id)}
71
- className="w-4 h-4 rounded-full bg-red-500/80 hover:bg-red-500 flex items-center justify-center transition-colors"
72
- />
73
- </div>
74
-
75
- {/* Transient Body */}
76
- <div className="p-4 bg-surface-overlay backdrop-blur-xl h-full w-full">
77
- {WidgetComponent ? (
78
- <PluginErrorBoundary pluginName={WidgetMeta.name} pluginId={WidgetMeta.pluginId}>
79
- <React.Suspense fallback={<div className="text-text-primary/50 p-4 text-center">Loading Floating Plugin...</div>}>
80
- <WidgetComponent {...(WidgetMeta.defaultProps || {})} {...(overlay.props || {})} />
81
- </React.Suspense>
82
- </PluginErrorBoundary>
83
- ) : (
84
- <div className="text-text-primary/50 text-center w-full h-full flex items-center justify-center">No Component</div>
85
- )}
86
- </div>
87
- </div>
88
- );
89
- })}
90
- </div>
91
- );
92
- };
@@ -1,134 +0,0 @@
1
- import React, { useState, useRef, useEffect } from 'react';
2
- import { motion, AnimatePresence } from 'motion/react';
3
- import { Sparkles, Terminal } from 'lucide-react';
4
- import { PlaygroundFloatingInput } from '../playground/PlaygroundFloatingInput';
5
-
6
- export interface AgentMessage {
7
- id: string;
8
- role: 'user' | 'agent' | 'system';
9
- text: string;
10
- toolCalls?: {
11
- name: string;
12
- args: any;
13
- status: 'pending' | 'running' | 'success' | 'error';
14
- output?: string;
15
- }[];
16
- }
17
-
18
- export interface AgentChatProps {
19
- messages: AgentMessage[];
20
- onSendMessage: (text: string) => void;
21
- isGenerating: boolean;
22
- agentName?: string;
23
- themeBrand?: string;
24
- }
25
-
26
- export const AgentChat: React.FC<AgentChatProps> = ({
27
- messages,
28
- onSendMessage,
29
- isGenerating,
30
- agentName = "Decido OS",
31
- themeBrand = "decido"
32
- }) => {
33
- const scrollRef = useRef<HTMLDivElement>(null);
34
-
35
- // Auto-scroll
36
- useEffect(() => {
37
- if (scrollRef.current) {
38
- scrollRef.current.scrollTo({ top: scrollRef.current.scrollHeight, behavior: 'smooth' });
39
- }
40
- }, [messages, isGenerating]);
41
-
42
- return (
43
- <div className="flex flex-col h-full overflow-hidden w-full max-w-4xl mx-auto pb-4 relative">
44
- <div ref={scrollRef} className="flex-1 overflow-y-auto pr-4 custom-scrollbar scroll-smooth flex flex-col gap-6 pb-20 mt-8">
45
-
46
- {messages.length === 0 && (
47
- <div className="flex flex-col gap-4">
48
- <h1 className="text-3xl font-semibold leading-tight text-text-primary/50">
49
- <span className="bg-gradient-to-r from-cyan-400 to-blue-500 text-transparent bg-clip-text">
50
- Modo Agente Autónomo
51
- </span><br/>
52
- ¿Qué vamos a construir en el Sandbox?
53
- </h1>
54
- <p className="text-sm text-text-muted font-mono">
55
- // {agentName} conectado al demonio Rust (core-rust) con ejecución nativa.
56
- </p>
57
- </div>
58
- )}
59
-
60
- {messages.map((msg) => (
61
- <div key={msg.id} className={`flex flex-col gap-2 ${msg.role === 'user' ? 'items-end' : 'items-start'}`}>
62
- {msg.text && (
63
- <div className={`p-4 rounded-2xl max-w-[85%] ${
64
- msg.role === 'user'
65
- ? 'bg-cyan-500/10 border border-cyan-500/20 text-cyan-50'
66
- : msg.role === 'system'
67
- ? 'bg-orange-500/10 border border-orange-500/20 text-orange-200 font-mono text-xs'
68
- : 'bg-surface-tertiary border border-border-subtle text-text-primary'
69
- }`}>
70
- {msg.text}
71
- </div>
72
- )}
73
-
74
- {/* Visualizador de Tool Calls */}
75
- {msg.toolCalls && msg.toolCalls.map((tc, idx) => (
76
- <div key={idx} className="w-full max-w-[85%] bg-[#0d1117] border border-border-strong rounded-lg overflow-hidden my-2">
77
- <div className="flex items-center gap-2 bg-[#161b22] px-3 py-2 border-b border-border-strong">
78
- <Terminal size={14} className="text-slate-400" />
79
- <span className="text-xs font-mono text-cyan-400 font-bold">{tc.name}</span>
80
- <span className="flex-1"></span>
81
- <span className={`text-[10px] uppercase font-bold px-2 py-0.5 rounded-full ${
82
- tc.status === 'running' ? 'bg-amber-500/20 text-amber-500 animate-pulse' :
83
- tc.status === 'success' ? 'bg-emerald-500/20 text-emerald-500' :
84
- tc.status === 'error' ? 'bg-red-500/20 text-red-500' :
85
- 'bg-slate-500/20 text-slate-500'
86
- }`}>
87
- {tc.status}
88
- </span>
89
- </div>
90
- <div className="p-3">
91
- <pre className="text-[10px] font-mono text-slate-300 whitespace-pre-wrap break-words">
92
- <span className="text-slate-500">// Argumentos:</span><br/>
93
- {JSON.stringify(tc.args, null, 2)}
94
- </pre>
95
- {tc.output && (
96
- <div className="mt-2 pt-2 border-t border-slate-800">
97
- <pre className="text-[10px] font-mono whitespace-pre-wrap break-words text-emerald-400/80">
98
- {tc.output.length > 500 ? tc.output.substring(0, 500) + '... [TRUNCADO]' : tc.output}
99
- </pre>
100
- </div>
101
- )}
102
- </div>
103
- </div>
104
- ))}
105
- </div>
106
- ))}
107
-
108
- <AnimatePresence>
109
- {isGenerating && (
110
- <motion.div initial={{ opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0 }} className="flex gap-4 items-center">
111
- <div className="w-8 h-8 rounded-full border border-cyan-500/30 flex items-center justify-center bg-cyan-500/10">
112
- <Sparkles size={14} className="text-cyan-400 animate-pulse" />
113
- </div>
114
- <span className="text-xs text-cyan-400/70 font-mono animate-pulse">Razonando siguiente acción...</span>
115
- </motion.div>
116
- )}
117
- </AnimatePresence>
118
- </div>
119
-
120
- <div className="shrink-0 w-full px-4 pb-2 z-50">
121
- <PlaygroundFloatingInput
122
- isGenerating={isGenerating}
123
- onSend={onSendMessage}
124
- isVoiceActive={false}
125
- setIsVoiceActive={() => {}}
126
- showCanvas={false}
127
- setShowCanvas={() => {}}
128
- prototypeBrand={themeBrand}
129
- setPrototypeBrand={() => {}}
130
- />
131
- </div>
132
- </div>
133
- );
134
- };
@@ -1,81 +0,0 @@
1
- /**
2
- * IntentCatalogPanel — Displays registered intent patterns with clickable examples.
3
- * Click an example → fills the chat input textarea.
4
- */
5
- import React, { useState } from 'react';
6
- import { motion, AnimatePresence } from 'motion/react';
7
- import { ChevronDown, Zap } from 'lucide-react';
8
- import { getIntentPatterns } from '../../hooks/useIntentLens';
9
-
10
- interface IntentCatalogPanelProps {
11
- onSelect: (text: string) => void;
12
- }
13
-
14
- export const IntentCatalogPanel = React.memo(function IntentCatalogPanel({ onSelect }: IntentCatalogPanelProps) {
15
- const patterns = getIntentPatterns();
16
- const [expanded, setExpanded] = useState<string | null>(null);
17
-
18
- return (
19
- <div className="w-full bg-surface-tertiary border border-border-default rounded-xl overflow-hidden shadow-2xl">
20
- <div className="px-3 py-2 flex items-center gap-2 border-b border-border-subtle">
21
- <Zap size={12} className="text-cyan-400" />
22
- <span className="text-[10px] text-text-muted font-mono uppercase tracking-wider">Intenciones Disponibles</span>
23
- </div>
24
- <div className="max-h-[240px] overflow-y-auto custom-scrollbar">
25
- {patterns.map(p => (
26
- <div key={p.type} className="border-b border-border-subtle last:border-0">
27
- {/* Intent Header */}
28
- <button
29
- onClick={() => setExpanded(expanded === p.type ? null : p.type)}
30
- className="w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-surface-glass transition-colors"
31
- >
32
- <span className="text-base leading-none">{p.icon}</span>
33
- <span className="font-semibold text-text-primary flex-1 text-left">{p.label}</span>
34
- <span
35
- className="w-2 h-2 rounded-full shrink-0"
36
- style={{ background: p.color }}
37
- />
38
- <ChevronDown
39
- size={12}
40
- className={`text-text-muted transition-transform ${expanded === p.type ? 'rotate-180' : ''}`}
41
- />
42
- </button>
43
-
44
- {/* Examples */}
45
- <AnimatePresence>
46
- {expanded === p.type && (
47
- <motion.div
48
- initial={{ height: 0, opacity: 0 }}
49
- animate={{ height: 'auto', opacity: 1 }}
50
- exit={{ height: 0, opacity: 0 }}
51
- transition={{ duration: 0.15 }}
52
- className="overflow-hidden"
53
- >
54
- <div className="px-3 pb-2 space-y-1">
55
- {p.examples.map((ex, i) => (
56
- <button
57
- key={i}
58
- onClick={() => onSelect(ex)}
59
- className="w-full text-left px-2.5 py-1.5 rounded-lg text-[11px] text-text-secondary hover:text-text-primary hover:bg-surface-glass transition-colors font-mono leading-snug flex items-center gap-2 group"
60
- >
61
- <span
62
- className="w-1 h-1 rounded-full shrink-0 opacity-40 group-hover:opacity-100 transition-opacity"
63
- style={{ background: p.color }}
64
- />
65
- <span className="flex-1">{ex}</span>
66
- <span className="text-[9px] text-text-muted opacity-0 group-hover:opacity-100 transition-opacity">↵</span>
67
- </button>
68
- ))}
69
- </div>
70
- </motion.div>
71
- )}
72
- </AnimatePresence>
73
- </div>
74
- ))}
75
- {patterns.length === 0 && (
76
- <div className="px-3 py-4 text-xs text-text-muted italic text-center">Sin intenciones registradas</div>
77
- )}
78
- </div>
79
- </div>
80
- );
81
- });
@@ -1,101 +0,0 @@
1
- /**
2
- * Slash command handler for PlaygroundChat.
3
- * Extracted to keep PlaygroundChat focused on rendering.
4
- */
5
- import { useTimelineStore } from '@decido/engine';
6
- import { useEngineStore } from '@decido/engine';
7
- import { useUIComponentStore } from '../../store/useUIComponentStore';
8
-
9
- interface SlashCommandContext {
10
- prototypeBrand: string;
11
- setPrototypeBrand: (val: string) => void;
12
- addChatMessage: (msg: any) => void;
13
- }
14
-
15
- /**
16
- * Processes a slash command and returns true if handled.
17
- */
18
- export function handleSlashCommand(input: string, ctx: SlashCommandContext): boolean {
19
- if (!input.startsWith('/')) return false;
20
-
21
- const parts = input.split(' ');
22
- const cmd = parts[0].toLowerCase();
23
- const arg = parts.slice(1).join(' ');
24
-
25
- switch (cmd) {
26
- case '/run': {
27
- if (!arg) return false;
28
- const timelines = useTimelineStore.getState().timelines;
29
- if (timelines[arg]) {
30
- ctx.setPrototypeBrand(arg);
31
- useEngineStore.getState().resetEngine();
32
- ctx.addChatMessage({ type: 'text', sender: 'system', text: `▶️ Ejecutando flujo: **${arg}**`, actorId: 'system' });
33
- setTimeout(() => { useEngineStore.getState().dispatchEvent({ type: 'SYSTEM_START' }); }, 100);
34
- } else {
35
- ctx.addChatMessage({ type: 'alert', sender: 'system', text: `Flujo "${arg}" no encontrado. Usa /flows para ver los disponibles.`, actorId: 'system' });
36
- }
37
- return true;
38
- }
39
- case '/flows': {
40
- const flowIds = Object.keys(useTimelineStore.getState().timelines);
41
- ctx.addChatMessage({ type: 'text', sender: 'system', text: `📋 Flujos disponibles:\n${flowIds.map(id => `• ${id}`).join('\n')}\n\nUsa /run [nombre] para ejecutar.`, actorId: 'system' });
42
- return true;
43
- }
44
- case '/blueprints': {
45
- const bps = Object.entries(useTimelineStore.getState().blueprintLibrary);
46
- ctx.addChatMessage({ type: 'text', sender: 'system', text: `📦 Blueprints:\n${bps.map(([id, bp]) => `• ${id} — ${bp.name || '?'}`).join('\n') || 'Ninguno registrado.'}`, actorId: 'system' });
47
- return true;
48
- }
49
- case '/ui': {
50
- if (arg) {
51
- const comp = useUIComponentStore.getState().components[arg];
52
- if (comp) ctx.addChatMessage({ type: 'ui-artifact', sender: 'agent', text: `🎨 ${comp.name}`, actorId: 'system', uiSchema: JSON.stringify(comp.schema) });
53
- else ctx.addChatMessage({ type: 'alert', sender: 'system', text: `Componente "${arg}" no encontrado.`, actorId: 'system' });
54
- } else {
55
- const uiComps = Object.values(useUIComponentStore.getState().components);
56
- ctx.addChatMessage({ type: 'text', sender: 'system', text: `🎨 UI Components:\n${uiComps.map(c => `• ${c.name} (${c.category}) — ${c.source}`).join('\n') || 'Ninguno.'}\n\nUsa /ui [id] para renderizar.`, actorId: 'system' });
57
- }
58
- return true;
59
- }
60
- case '/tts': {
61
- if (!arg) {
62
- ctx.addChatMessage({ type: 'alert', sender: 'system', text: `Debes indicar el texto a leer. Ejemplo:\n/tts Hola mundo`, actorId: 'system' });
63
- return true;
64
- }
65
- ctx.addChatMessage({ type: 'text', sender: 'system', text: `🎙️ Generando audio neuronal para:\n"${arg}"...`, actorId: 'system' });
66
-
67
- import('@decido/kernel-bridge').then(({ kernel }) => {
68
- kernel.execute<string>('call_mcp_tool', {
69
- server_name: "Kokoro TTS",
70
- tool_name: "generate_tts",
71
- arguments: { text: arg, voice: "em_alex", speed: 1.0, lang: "es", return_base64: true }
72
- }).then((res: string) => {
73
- const messageText = typeof res === 'string' ? res : JSON.stringify(res);
74
- if (messageText.includes('DATA_URI:')) {
75
- const dataUri = messageText.split('DATA_URI:')[1].trim();
76
- ctx.addChatMessage({
77
- type: 'audio',
78
- sender: 'system',
79
- text: `✅ Emisión de voz generada con éxito`,
80
- audioSrc: dataUri,
81
- actorId: 'system'
82
- });
83
- } else {
84
- ctx.addChatMessage({ type: 'alert', sender: 'system', text: `La respuesta no incluyó un URI válido:\n${messageText}`, actorId: 'system' });
85
- }
86
- }).catch((err: any) => {
87
- ctx.addChatMessage({ type: 'alert', sender: 'system', text: `❌ Error de TTS: ${String(err)}`, actorId: 'system' });
88
- });
89
- });
90
- return true;
91
- }
92
- case '/reset': {
93
- useEngineStore.getState().resetEngine();
94
- ctx.addChatMessage({ type: 'text', sender: 'system', text: '⏹ Motor reiniciado.', actorId: 'system' });
95
- return true;
96
- }
97
- default:
98
- ctx.addChatMessage({ type: 'alert', sender: 'system', text: `Comando desconocido: ${cmd}`, actorId: 'system' });
99
- return true;
100
- }
101
- }