@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.
- package/.turbo/turbo-build.log +13 -0
- package/package.json +65 -0
- package/src/AgentPlayer.tsx +105 -0
- package/src/DecidoPlayer.tsx +117 -0
- package/src/bridge/BridgeAgent.ts +443 -0
- package/src/components/DecidoIcon.tsx +56 -0
- package/src/components/JsonTreeEditor.tsx +117 -0
- package/src/components/PanelSplitter.tsx +71 -0
- package/src/components/PluginErrorBoundary.tsx +69 -0
- package/src/components/SafeLiquidUI.tsx +114 -0
- package/src/components/TransientLayer.tsx +92 -0
- package/src/components/agent/AgentChat.tsx +134 -0
- package/src/components/chat-extensions/IntentCatalogPanel.tsx +81 -0
- package/src/components/chat-extensions/chatSlashCommands.ts +101 -0
- package/src/components/controls/CreatorInputBar.tsx +144 -0
- package/src/components/controls/OSToolbar.tsx +90 -0
- package/src/components/controls/TimelineTape.tsx +43 -0
- package/src/components/debug/ActionTimelineTab.tsx +111 -0
- package/src/components/debug/CSSInspectorTab.tsx +436 -0
- package/src/components/debug/ExportTab.tsx +192 -0
- package/src/components/debug/FlowHealthTab.tsx +86 -0
- package/src/components/debug/LogsTab.tsx +110 -0
- package/src/components/debug/MorphStackTab.tsx +241 -0
- package/src/components/debug/NetworkTab.tsx +173 -0
- package/src/components/debug/PerformanceTab.tsx +171 -0
- package/src/components/debug/ProfilesTab.tsx +238 -0
- package/src/components/debug/ReplayTab.tsx +70 -0
- package/src/components/debug/StoresTab.tsx +255 -0
- package/src/components/debug/TopologyTab.tsx +59 -0
- package/src/components/debug/debugConfig.tsx +66 -0
- package/src/components/playground/DebugPanel.tsx +112 -0
- package/src/components/playground/HeaderCenterControls.tsx +92 -0
- package/src/components/playground/KeyframeListItem.tsx +70 -0
- package/src/components/playground/PlaygroundAppSidebar.tsx +171 -0
- package/src/components/playground/PlaygroundBottomControls.tsx +132 -0
- package/src/components/playground/PlaygroundCanvas.tsx +87 -0
- package/src/components/playground/PlaygroundChat.tsx +236 -0
- package/src/components/playground/PlaygroundErrorBoundary.tsx +63 -0
- package/src/components/playground/PlaygroundFloatingInput.tsx +352 -0
- package/src/components/playground/PlaygroundHeader.tsx +222 -0
- package/src/components/playground/PlaygroundSidebar.tsx +136 -0
- package/src/components/playground/PlaygroundTerminal.tsx +44 -0
- package/src/components/playground/SuggestionCards.tsx +29 -0
- package/src/components/playground/demos/ClinicaAINode.tsx +221 -0
- package/src/components/playground/demos/FinanceAINode.tsx +226 -0
- package/src/components/playground/demos/KiaAcademyNode.tsx +250 -0
- package/src/components/playground/demos/KiaBotNode.tsx +207 -0
- package/src/components/playground/demos/KiaCampaignNode.tsx +191 -0
- package/src/components/playground/demos/KiaComplianceNode.tsx +140 -0
- package/src/components/playground/demos/KiaCustomerJourneyNode.tsx +220 -0
- package/src/components/playground/demos/KiaCyberNode.tsx +203 -0
- package/src/components/playground/demos/KiaDashboardNode.tsx +399 -0
- package/src/components/playground/demos/KiaEmbudoOverviewNode.tsx +168 -0
- package/src/components/playground/demos/KiaExecutiveNode.tsx +169 -0
- package/src/components/playground/demos/KiaGamificationNode.tsx +229 -0
- package/src/components/playground/demos/KiaIntelligenceHubNode.tsx +165 -0
- package/src/components/playground/demos/KiaInventoryNode.tsx +183 -0
- package/src/components/playground/demos/KiaLeadScoringNode.tsx +226 -0
- package/src/components/playground/demos/KiaLiveSimulationNode.tsx +177 -0
- package/src/components/playground/demos/KiaMultiDealerNode.tsx +223 -0
- package/src/components/playground/demos/KiaNPSVoiceNode.tsx +214 -0
- package/src/components/playground/demos/KiaOmnichannelNode.tsx +162 -0
- package/src/components/playground/demos/KiaPBIBudgetNode.tsx +152 -0
- package/src/components/playground/demos/KiaPBIConversionNode.tsx +206 -0
- package/src/components/playground/demos/KiaPBIFunnelNode.tsx +184 -0
- package/src/components/playground/demos/KiaPBIOwnershipNode.tsx +113 -0
- package/src/components/playground/demos/KiaPBIPartnerNode.tsx +143 -0
- package/src/components/playground/demos/KiaPBIPreciosNode.tsx +120 -0
- package/src/components/playground/demos/KiaPBIRuntNode.tsx +205 -0
- package/src/components/playground/demos/KiaPartnerScoreNode.tsx +206 -0
- package/src/components/playground/demos/KiaPredictiveNode.tsx +226 -0
- package/src/components/playground/demos/KiaShowroomNode.tsx +194 -0
- package/src/components/playground/demos/KiaStoreNode.tsx +215 -0
- package/src/components/playground/demos/KiaSustainabilityNode.tsx +173 -0
- package/src/components/playground/demos/KiaUsedVehiclesNode.tsx +163 -0
- package/src/components/playground/demos/KiaWorkshopNode.tsx +221 -0
- package/src/components/playground/demos/SmartCityNode.tsx +205 -0
- package/src/components/playground/demos/kia_campaign_manifest.json +112 -0
- package/src/components/playground/input-parts/AIModelSelector.tsx +156 -0
- package/src/components/playground/input-parts/InputActions.tsx +80 -0
- package/src/components/playground/input-parts/InputToolbar.tsx +245 -0
- package/src/components/playground/input-parts/ResourceLibraryPanel.tsx +287 -0
- package/src/components/playground/sidebarDsdIO.ts +82 -0
- package/src/components/settings/SettingsPanel.tsx +267 -0
- package/src/components/shell/AppHeader.tsx +9 -0
- package/src/components/shell/AppShell.tsx +139 -0
- package/src/components/shell/ArtifactBar.tsx +97 -0
- package/src/components/shell/BootScreen.tsx +19 -0
- package/src/components/shell/CenterComposite.tsx +87 -0
- package/src/components/shell/CodeEditorPanel.tsx +88 -0
- package/src/components/shell/GlobalOverlays.tsx +228 -0
- package/src/components/shell/LayoutConfigurator.tsx +209 -0
- package/src/components/shell/LayoutGrid.tsx +178 -0
- package/src/components/shell/MorphShell.tsx +368 -0
- package/src/components/shell/PluginViewer.tsx +147 -0
- package/src/components/shell/ShellNexusPreview.tsx +458 -0
- package/src/components/shell/SlotRenderer.tsx +115 -0
- package/src/components/shell/TabBar.tsx +94 -0
- package/src/components/shell/TemplateLibrary.tsx +195 -0
- package/src/components/shell/layoutConstants.ts +35 -0
- package/src/components/shell/morphStageMeta.ts +15 -0
- package/src/components/shell/shells/BuiltInShells.tsx +443 -0
- package/src/components/shell/shells/DatawayChatShell.tsx +42 -0
- package/src/components/shell/shells/TokenPreview.tsx +339 -0
- package/src/components/shell/shells/bootShells.ts +31 -0
- package/src/components/shells/CreatorShell.tsx +37 -0
- package/src/components/shells/DecidoShell.tsx +447 -0
- package/src/components/shells/ExperimentalChatShell.tsx +245 -0
- package/src/components/shells/UserCanvas.tsx +44 -0
- package/src/components/studio/BlueprintManagerPanel.tsx +137 -0
- package/src/components/studio/DependencyTreePanel.tsx +192 -0
- package/src/components/studio/NodePalette.tsx +92 -0
- package/src/components/studio/NodePropertiesPanel.tsx +81 -0
- package/src/components/studio/ReactFlowEditor.tsx +242 -0
- package/src/components/studio/TimelineEditor.tsx +122 -0
- package/src/components/studio/TimelineKeyframeCard.tsx +99 -0
- package/src/components/studio/VariablePanel.tsx +181 -0
- package/src/components/studio/blueprint/BlueprintCard.tsx +82 -0
- package/src/components/studio/editor/CanvasContextMenu.tsx +107 -0
- package/src/components/studio/editor/EditorToolbar.tsx +80 -0
- package/src/components/studio/editor/StageContentRenderer.tsx +134 -0
- package/src/components/studio/editor/TrackPropertyEditors.tsx +133 -0
- package/src/components/studio/editor/TreeNodeItem.tsx +91 -0
- package/src/components/studio/editor/edgeStyles.ts +43 -0
- package/src/components/studio/editor/editorKeyHandler.ts +95 -0
- package/src/components/studio/editor/nodeTypeRegistry.ts +137 -0
- package/src/components/studio/editor/paletteCatalog.tsx +84 -0
- package/src/components/studio/nodes/shell/InteractionNodes.tsx +82 -0
- package/src/components/studio/nodes/shell/LayoutControlNodes.tsx +69 -0
- package/src/components/studio/nodes/shell/RegisterActionNode.tsx +20 -0
- package/src/components/studio/nodes/shell/RegisterButtonNode.tsx +22 -0
- package/src/components/studio/nodes/shell/RegisterPanelNode.tsx +19 -0
- package/src/components/studio/nodes/shell/RegisterSidebarNode.tsx +19 -0
- package/src/components/studio/nodes/shell/RegisterStatusBarNode.tsx +22 -0
- package/src/components/studio/nodes/shell/RegisterTabNode.tsx +21 -0
- package/src/components/studio/nodes/shell/RegisterTopBarNode.tsx +22 -0
- package/src/components/studio/nodes/shell/ShellConfigNode.tsx +51 -0
- package/src/components/studio/nodes/shell/ShellNodeBase.tsx +100 -0
- package/src/components/studio/nodes/shell/ThemeNodes.tsx +51 -0
- package/src/components/studio/nodes/shell/index.ts +12 -0
- package/src/components/widgets/BroadcastWidget.tsx +93 -0
- package/src/components/widgets/MarketplaceWidget.tsx +298 -0
- package/src/components/widgets/McpToolsWidget.tsx +231 -0
- package/src/components/widgets/OpsDashboard.tsx +59 -0
- package/src/components/widgets/QuickActionsWidget.tsx +60 -0
- package/src/components/widgets/UsageWidget.tsx +112 -0
- package/src/components/widgets/WidgetRenderer.tsx +892 -0
- package/src/components/widgets/WidgetSlotPanel.tsx +213 -0
- package/src/config/IconRegistry.ts +126 -0
- package/src/contexts/NetworkProvider.tsx +162 -0
- package/src/core/AIDirector.ts +71 -0
- package/src/core/EventBus.ts +37 -0
- package/src/core/PluginContext.tsx +141 -0
- package/src/hooks/listeners/useUIStateListener.ts +59 -0
- package/src/hooks/listeners/useWhatsAppListener.ts +110 -0
- package/src/hooks/morphBridge.ts +82 -0
- package/src/hooks/useAIModelSelector.ts +144 -0
- package/src/hooks/useAgentStream.ts +220 -0
- package/src/hooks/useAutoUpdater.ts +89 -0
- package/src/hooks/useBootSequence.ts +20 -0
- package/src/hooks/useExportDSD.ts +53 -0
- package/src/hooks/useFullscreen.ts +35 -0
- package/src/hooks/useGeminiStream.ts +282 -0
- package/src/hooks/useIntentLens.ts +224 -0
- package/src/hooks/useKeyboardShortcuts.ts +69 -0
- package/src/hooks/useLoggerBridge.ts +32 -0
- package/src/hooks/useMcpClient.ts +112 -0
- package/src/hooks/useNexusaiDeploy.ts +118 -0
- package/src/hooks/usePlaybackEngine.ts +21 -0
- package/src/hooks/usePlaygroundCommander.ts +475 -0
- package/src/hooks/usePluginEngine.ts +165 -0
- package/src/hooks/useScreenRecorder.ts +73 -0
- package/src/hooks/useShellKeyboard.ts +40 -0
- package/src/hooks/useShellShortcuts.ts +118 -0
- package/src/hooks/useSoundEffects.ts +35 -0
- package/src/hooks/useStudioConfig.ts +72 -0
- package/src/hooks/useSystemBoot.ts +84 -0
- package/src/hooks/useSystemTelemetry.ts +62 -0
- package/src/index.ts +97 -0
- package/src/lib/debugLogger.ts +80 -0
- package/src/lib/networkInterceptor.ts +100 -0
- package/src/mocks/decido.tsx +41 -0
- package/src/plugins/pluginAPI.ts +190 -0
- package/src/store/McpStore.ts +69 -0
- package/src/store/UpdaterStore.ts +60 -0
- package/src/store/engine.ts +392 -0
- package/src/store/index.ts +4 -0
- package/src/store/layoutPresets.ts +66 -0
- package/src/store/playgroundTypes.ts +98 -0
- package/src/store/useActionTimelineStore.ts +48 -0
- package/src/store/useDebugPanelStore.ts +98 -0
- package/src/store/useDebugProfileStore.ts +130 -0
- package/src/store/useLayoutStore.ts +205 -0
- package/src/store/useMorphInstanceStore.ts +289 -0
- package/src/store/useMorphologyStore.ts +103 -0
- package/src/store/usePlaygroundStore.ts +236 -0
- package/src/store/useShellRegistry.ts +123 -0
- package/src/store/useSuggestionsStore.ts +57 -0
- package/src/store/useThemeStore.ts +399 -0
- package/src/store/useUIComponentStore.ts +179 -0
- package/src/types/DecidoStoryDefinition.ts +43 -0
- package/src/utils/ai/ai-architect.ts +92 -0
- package/src/utils/ai/ai-code.ts +187 -0
- package/src/utils/ai/ai-core.ts +50 -0
- package/src/utils/ai/ai-media.ts +292 -0
- package/src/utils/layoutGraph.ts +67 -0
- package/tsconfig.json +17 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
}
|