@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,292 @@
1
+ // ═══════════════════════════════════════════════════════
2
+ // AI Media — Video, Audio, Image Generation
3
+ // ═══════════════════════════════════════════════════════
4
+
5
+ import { Type, Modality } from "@google/genai";
6
+ import { getClient, getGlobalSettings, logger } from './ai-core';
7
+ import { ScriptScene } from '@decido/canvas-core';
8
+
9
+ // --- WAV HELPERS ---
10
+
11
+ function addWavHeader(samples: Uint8Array, sampleRate: number = 24000, numChannels: number = 1): ArrayBuffer {
12
+ const buffer = new ArrayBuffer(44 + samples.length);
13
+ const view = new DataView(buffer);
14
+
15
+ writeString(view, 0, 'RIFF');
16
+ view.setUint32(4, 36 + samples.length, true);
17
+ writeString(view, 8, 'WAVE');
18
+ writeString(view, 12, 'fmt ');
19
+ view.setUint32(16, 16, true);
20
+ view.setUint16(20, 1, true);
21
+ view.setUint16(22, numChannels, true);
22
+ view.setUint32(24, sampleRate, true);
23
+ view.setUint32(28, sampleRate * numChannels * 2, true);
24
+ view.setUint16(32, numChannels * 2, true);
25
+ view.setUint16(34, 16, true);
26
+ writeString(view, 36, 'data');
27
+ view.setUint32(40, samples.length, true);
28
+
29
+ const dataView = new Uint8Array(buffer, 44);
30
+ dataView.set(samples);
31
+
32
+ return buffer;
33
+ }
34
+
35
+ function writeString(view: DataView, offset: number, string: string) {
36
+ for (let i = 0; i < string.length; i++) {
37
+ view.setUint8(offset + i, string.charCodeAt(i));
38
+ }
39
+ }
40
+
41
+ export function base64ToUint8Array(base64: string): Uint8Array {
42
+ const binaryString = atob(base64);
43
+ const len = binaryString.length;
44
+ const bytes = new Uint8Array(len);
45
+ for (let i = 0; i < len; i++) {
46
+ bytes[i] = binaryString.charCodeAt(i);
47
+ }
48
+ return bytes;
49
+ }
50
+
51
+ export function arrayBufferToBase64(buffer: ArrayBuffer): string {
52
+ let binary = '';
53
+ const bytes = new Uint8Array(buffer);
54
+ const len = bytes.byteLength;
55
+ for (let i = 0; i < len; i++) {
56
+ binary += String.fromCharCode(bytes[i]);
57
+ }
58
+ return btoa(binary);
59
+ }
60
+
61
+ export const blobToBase64 = (blob: Blob): Promise<string> => {
62
+ return new Promise((resolve, reject) => {
63
+ const reader = new FileReader();
64
+ reader.onloadend = () => {
65
+ const base64String = reader.result as string;
66
+ const base64Data = base64String.split(',')[1];
67
+ resolve(base64Data);
68
+ };
69
+ reader.onerror = reject;
70
+ reader.readAsDataURL(blob);
71
+ });
72
+ };
73
+
74
+
75
+ // --- VIDEO SCRIPT ---
76
+
77
+ export const generateVideoScript = async (concept: string, style: string): Promise<ScriptScene[]> => {
78
+ const client = getClient('text');
79
+ if (!client) return [];
80
+ const settings = getGlobalSettings();
81
+
82
+ try {
83
+ const response = await client.models.generateContent({
84
+ model: settings.text.model || 'gemini-3-flash-preview',
85
+ contents: `Write a 4-scene video script for: "${concept}". Style: ${style}.
86
+
87
+ IMPORTANT RULES:
88
+ 1. Detect the language of the concept (e.g., Spanish, French, English).
89
+ 2. Write the 'narration' and 'visualPrompt' in that SAME language.
90
+ 3. Return a JSON array.`,
91
+ config: {
92
+ responseMimeType: "application/json",
93
+ responseSchema: {
94
+ type: Type.ARRAY,
95
+ items: {
96
+ type: Type.OBJECT,
97
+ properties: {
98
+ sceneNumber: { type: Type.INTEGER },
99
+ narration: { type: Type.STRING },
100
+ visualPrompt: { type: Type.STRING },
101
+ cameraAngle: { type: Type.STRING },
102
+ duration: { type: Type.NUMBER }
103
+ },
104
+ required: ["sceneNumber", "narration", "visualPrompt", "duration"]
105
+ }
106
+ }
107
+ }
108
+ });
109
+
110
+ const text = response.text;
111
+ if (!text) return [];
112
+ const rawScenes = JSON.parse(text);
113
+
114
+ return rawScenes.map((s: any) => ({
115
+ ...s,
116
+ id: `scene-${Date.now()}-${Math.random()}`,
117
+ status: 'idle'
118
+ }));
119
+
120
+ } catch (error) {
121
+ logger.error("Script Gen Error:", error);
122
+ return [];
123
+ }
124
+ };
125
+
126
+ // --- IMAGE GENERATION ---
127
+
128
+ export const generateKeyframe = async (prompt: string, aspectRatio: '16:9' | '9:16' | '1:1' = '16:9'): Promise<{ url: string | null; error?: string }> => {
129
+ const client = getClient('image');
130
+ if (!client) return { url: null, error: "API Key Config Missing" };
131
+ const settings = getGlobalSettings();
132
+ const selectedModel = settings.image.model || 'gemini-3-pro-image-preview';
133
+
134
+ const attemptGeneration = async (model: string, config: any) => {
135
+ const response = await client.models.generateContent({
136
+ model: model,
137
+ contents: { parts: [{ text: prompt }] },
138
+ config: config
139
+ });
140
+ for (const part of response.candidates?.[0]?.content?.parts || []) {
141
+ if (part.inlineData) {
142
+ return `data:image/png;base64,${part.inlineData.data}`;
143
+ }
144
+ }
145
+ return null;
146
+ };
147
+
148
+ try {
149
+ const url = await attemptGeneration(selectedModel, {
150
+ imageConfig: {
151
+ aspectRatio: aspectRatio,
152
+ imageSize: selectedModel.includes('pro') ? '1K' : undefined
153
+ }
154
+ });
155
+ return { url };
156
+
157
+ } catch (error: any) {
158
+ logger.warn(`${selectedModel} failed, checking fallback...`, error);
159
+
160
+ if (selectedModel.includes('pro') && (error.status === 429 || (error.message && error.message.includes('429')))) {
161
+ try {
162
+ const url = await attemptGeneration('gemini-2.5-flash-image', {
163
+ imageConfig: { aspectRatio: aspectRatio }
164
+ });
165
+ if (url) return { url };
166
+ } catch (fallbackError: any) {
167
+ return { url: null, error: "Quota Exceeded (All Models). Try again later." };
168
+ }
169
+ }
170
+
171
+ return { url: null, error: error.message || "Image Generation Failed" };
172
+ }
173
+ };
174
+
175
+ // --- VIDEO GENERATION (VEO) ---
176
+
177
+ export const generateVeoVideo = async (imageBase64: string, prompt: string, aspectRatio: '16:9' | '9:16' = '16:9'): Promise<{ url: string | null; error?: string }> => {
178
+ const client = getClient('video');
179
+ if (!client) return { url: null, error: "API Key Config Missing" };
180
+ const settings = getGlobalSettings();
181
+
182
+ // Check implementation specific window object if needed, skipping for shared package
183
+
184
+ try {
185
+ const base64Data = imageBase64.split(',')[1] || imageBase64;
186
+
187
+ let operation = await client.models.generateVideos({
188
+ model: settings.video.model || 'veo-3.1-generate-preview',
189
+ prompt: prompt,
190
+ image: {
191
+ imageBytes: base64Data,
192
+ mimeType: 'image/png'
193
+ },
194
+ config: {
195
+ numberOfVideos: 1,
196
+ resolution: '720p',
197
+ aspectRatio: aspectRatio
198
+ }
199
+ });
200
+
201
+ while (!operation.done) {
202
+ await new Promise(resolve => setTimeout(resolve, 5000));
203
+ operation = await client.operations.getVideosOperation({ operation: operation });
204
+ }
205
+
206
+ const videoUri = operation.response?.generatedVideos?.[0]?.video?.uri;
207
+
208
+ if (videoUri) {
209
+ const keyToUse = settings.video.apiKey || process.env.VITE_API_KEY;
210
+ return { url: `${videoUri}&key=${keyToUse}` };
211
+ }
212
+ return { url: null, error: "Video generation completed but returned no URI." };
213
+
214
+ } catch (error: any) {
215
+ logger.error("Veo Gen Error:", error);
216
+ return { url: null, error: error.message || "Video Generation Failed (Quota or Server Error)" };
217
+ }
218
+ };
219
+
220
+ // --- SPEECH GENERATION ---
221
+
222
+ export const generateSpeech = async (text: string, voiceName: string = 'Kore'): Promise<string | null> => {
223
+ const client = getClient('audio');
224
+ if (!client) return null;
225
+ const settings = getGlobalSettings();
226
+
227
+ try {
228
+ const response = await client.models.generateContent({
229
+ model: settings.audio.model || "gemini-2.5-flash-preview-tts",
230
+ contents: [{ parts: [{ text }] }],
231
+ config: {
232
+ responseModalities: [Modality.AUDIO],
233
+ speechConfig: {
234
+ voiceConfig: {
235
+ prebuiltVoiceConfig: { voiceName }
236
+ },
237
+ },
238
+ },
239
+ });
240
+
241
+ const base64PCM = response.candidates?.[0]?.content?.parts?.[0]?.inlineData?.data;
242
+
243
+ if (base64PCM) {
244
+ const pcmData = base64ToUint8Array(base64PCM);
245
+ const wavBuffer = addWavHeader(pcmData, 24000, 1);
246
+ const wavBase64 = arrayBufferToBase64(wavBuffer);
247
+ return `data:audio/wav;base64,${wavBase64}`;
248
+ }
249
+ return null;
250
+ } catch (error) {
251
+ logger.error("TTS Error:", error);
252
+ return null;
253
+ }
254
+ };
255
+
256
+ export const analyzeAudio = async (audioBlob: Blob, task: 'TRANSCRIPTION' | 'SUMMARY'): Promise<string> => {
257
+ const client = getClient('text');
258
+ if (!client) return "API Key Missing";
259
+ const settings = getGlobalSettings();
260
+
261
+ try {
262
+ const base64Audio = await blobToBase64(audioBlob);
263
+
264
+ let prompt = "";
265
+ if (task === 'TRANSCRIPTION') {
266
+ prompt = "Transcribe the following audio accurately. Return only the text. Detect the language automatically.";
267
+ } else {
268
+ prompt = "Provide a concise summary of the key points discussed in this audio. Respond in the same language as the audio.";
269
+ }
270
+
271
+ const response = await client.models.generateContent({
272
+ model: settings.text.model || 'gemini-3-flash-preview',
273
+ contents: {
274
+ parts: [
275
+ {
276
+ inlineData: {
277
+ mimeType: audioBlob.type,
278
+ data: base64Audio
279
+ }
280
+ },
281
+ { text: prompt }
282
+ ]
283
+ }
284
+ });
285
+
286
+ return response.text || "No result generated.";
287
+
288
+ } catch (error) {
289
+ logger.error("AI Audio Error:", error);
290
+ return "Failed to process audio.";
291
+ }
292
+ };
@@ -0,0 +1,67 @@
1
+ import Dagre from '@dagrejs/dagre';
2
+ import type { Node, Edge } from '@xyflow/react';
3
+
4
+ interface LayoutOptions {
5
+ direction?: 'TB' | 'LR' | 'BT' | 'RL'; // Top-Bottom, Left-Right, etc.
6
+ nodeWidth?: number;
7
+ nodeHeight?: number;
8
+ rankSep?: number; // Vertical gap between ranks
9
+ nodeSep?: number; // Horizontal gap between nodes in same rank
10
+ }
11
+
12
+ /**
13
+ * Uses Dagre to compute a hierarchical auto-layout for React Flow nodes.
14
+ * Returns new nodes with updated positions. Does NOT mutate input.
15
+ */
16
+ export function getLayoutedElements(
17
+ nodes: Node[],
18
+ edges: Edge[],
19
+ options: LayoutOptions = {}
20
+ ): { nodes: Node[]; edges: Edge[] } {
21
+ const {
22
+ direction = 'TB',
23
+ nodeWidth = 260,
24
+ nodeHeight = 180,
25
+ rankSep = 100,
26
+ nodeSep = 80,
27
+ } = options;
28
+
29
+ const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
30
+
31
+ g.setGraph({
32
+ rankdir: direction,
33
+ ranksep: rankSep,
34
+ nodesep: nodeSep,
35
+ marginx: 50,
36
+ marginy: 50,
37
+ });
38
+
39
+ nodes.forEach((node) => {
40
+ // Use actual node dimensions if available, fallback to defaults
41
+ const w = (node.measured?.width) || nodeWidth;
42
+ const h = (node.measured?.height) || nodeHeight;
43
+ g.setNode(node.id, { width: w, height: h });
44
+ });
45
+
46
+ edges.forEach((edge) => {
47
+ g.setEdge(edge.source, edge.target);
48
+ });
49
+
50
+ Dagre.layout(g);
51
+
52
+ const layoutedNodes = nodes.map((node) => {
53
+ const dagNode = g.node(node.id);
54
+ const w = (node.measured?.width) || nodeWidth;
55
+ const h = (node.measured?.height) || nodeHeight;
56
+
57
+ return {
58
+ ...node,
59
+ position: {
60
+ x: dagNode.x - w / 2,
61
+ y: dagNode.y - h / 2,
62
+ },
63
+ };
64
+ });
65
+
66
+ return { nodes: layoutedNodes, edges };
67
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "baseUrl": ".",
6
+ "paths": {
7
+ "~/*": ["./src/*"],
8
+ "@decido/contracts": ["../contracts/src"],
9
+ "@decido/plugin-engine": ["../plugin-engine/src"],
10
+ "@decido/shell-auth": ["../shell-auth/src"],
11
+ "@decido/shell-telemetry": ["../shell-telemetry/src"]
12
+ }
13
+ },
14
+ "include": [
15
+ "src"
16
+ ]
17
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/agentplayer.tsx","./src/decidoplayer.tsx","./src/index.ts","./src/bridge/bridgeagent.ts","./src/components/decidoicon.tsx","./src/components/jsontreeeditor.tsx","./src/components/panelsplitter.tsx","./src/components/pluginerrorboundary.tsx","./src/components/safeliquidui.tsx","./src/components/transientlayer.tsx","./src/components/agent/agentchat.tsx","./src/components/chat-extensions/intentcatalogpanel.tsx","./src/components/chat-extensions/chatslashcommands.ts","./src/components/controls/creatorinputbar.tsx","./src/components/controls/ostoolbar.tsx","./src/components/controls/timelinetape.tsx","./src/components/debug/actiontimelinetab.tsx","./src/components/debug/cssinspectortab.tsx","./src/components/debug/exporttab.tsx","./src/components/debug/flowhealthtab.tsx","./src/components/debug/logstab.tsx","./src/components/debug/morphstacktab.tsx","./src/components/debug/networktab.tsx","./src/components/debug/performancetab.tsx","./src/components/debug/profilestab.tsx","./src/components/debug/replaytab.tsx","./src/components/debug/storestab.tsx","./src/components/debug/topologytab.tsx","./src/components/debug/debugconfig.tsx","./src/components/playground/debugpanel.tsx","./src/components/playground/headercentercontrols.tsx","./src/components/playground/keyframelistitem.tsx","./src/components/playground/playgroundappsidebar.tsx","./src/components/playground/playgroundbottomcontrols.tsx","./src/components/playground/playgroundcanvas.tsx","./src/components/playground/playgroundchat.tsx","./src/components/playground/playgrounderrorboundary.tsx","./src/components/playground/playgroundfloatinginput.tsx","./src/components/playground/playgroundheader.tsx","./src/components/playground/playgroundsidebar.tsx","./src/components/playground/playgroundterminal.tsx","./src/components/playground/suggestioncards.tsx","./src/components/playground/sidebardsdio.ts","./src/components/playground/demos/clinicaainode.tsx","./src/components/playground/demos/financeainode.tsx","./src/components/playground/demos/kiaacademynode.tsx","./src/components/playground/demos/kiabotnode.tsx","./src/components/playground/demos/kiacampaignnode.tsx","./src/components/playground/demos/kiacompliancenode.tsx","./src/components/playground/demos/kiacustomerjourneynode.tsx","./src/components/playground/demos/kiacybernode.tsx","./src/components/playground/demos/kiadashboardnode.tsx","./src/components/playground/demos/kiaembudooverviewnode.tsx","./src/components/playground/demos/kiaexecutivenode.tsx","./src/components/playground/demos/kiagamificationnode.tsx","./src/components/playground/demos/kiaintelligencehubnode.tsx","./src/components/playground/demos/kiainventorynode.tsx","./src/components/playground/demos/kialeadscoringnode.tsx","./src/components/playground/demos/kialivesimulationnode.tsx","./src/components/playground/demos/kiamultidealernode.tsx","./src/components/playground/demos/kianpsvoicenode.tsx","./src/components/playground/demos/kiaomnichannelnode.tsx","./src/components/playground/demos/kiapbibudgetnode.tsx","./src/components/playground/demos/kiapbiconversionnode.tsx","./src/components/playground/demos/kiapbifunnelnode.tsx","./src/components/playground/demos/kiapbiownershipnode.tsx","./src/components/playground/demos/kiapbipartnernode.tsx","./src/components/playground/demos/kiapbipreciosnode.tsx","./src/components/playground/demos/kiapbiruntnode.tsx","./src/components/playground/demos/kiapartnerscorenode.tsx","./src/components/playground/demos/kiapredictivenode.tsx","./src/components/playground/demos/kiashowroomnode.tsx","./src/components/playground/demos/kiastorenode.tsx","./src/components/playground/demos/kiasustainabilitynode.tsx","./src/components/playground/demos/kiausedvehiclesnode.tsx","./src/components/playground/demos/kiaworkshopnode.tsx","./src/components/playground/demos/smartcitynode.tsx","./src/components/playground/input-parts/aimodelselector.tsx","./src/components/playground/input-parts/inputactions.tsx","./src/components/playground/input-parts/inputtoolbar.tsx","./src/components/playground/input-parts/resourcelibrarypanel.tsx","./src/components/settings/settingspanel.tsx","./src/components/shell/appheader.tsx","./src/components/shell/appshell.tsx","./src/components/shell/artifactbar.tsx","./src/components/shell/bootscreen.tsx","./src/components/shell/centercomposite.tsx","./src/components/shell/codeeditorpanel.tsx","./src/components/shell/globaloverlays.tsx","./src/components/shell/layoutconfigurator.tsx","./src/components/shell/layoutgrid.tsx","./src/components/shell/morphshell.tsx","./src/components/shell/pluginviewer.tsx","./src/components/shell/shellnexuspreview.tsx","./src/components/shell/slotrenderer.tsx","./src/components/shell/tabbar.tsx","./src/components/shell/templatelibrary.tsx","./src/components/shell/layoutconstants.ts","./src/components/shell/morphstagemeta.ts","./src/components/shell/shells/builtinshells.tsx","./src/components/shell/shells/datawaychatshell.tsx","./src/components/shell/shells/tokenpreview.tsx","./src/components/shell/shells/bootshells.ts","./src/components/shells/creatorshell.tsx","./src/components/shells/decidoshell.tsx","./src/components/shells/experimentalchatshell.tsx","./src/components/shells/usercanvas.tsx","./src/components/studio/blueprintmanagerpanel.tsx","./src/components/studio/dependencytreepanel.tsx","./src/components/studio/nodepalette.tsx","./src/components/studio/nodepropertiespanel.tsx","./src/components/studio/reactfloweditor.tsx","./src/components/studio/timelineeditor.tsx","./src/components/studio/timelinekeyframecard.tsx","./src/components/studio/variablepanel.tsx","./src/components/studio/blueprint/blueprintcard.tsx","./src/components/studio/editor/canvascontextmenu.tsx","./src/components/studio/editor/editortoolbar.tsx","./src/components/studio/editor/stagecontentrenderer.tsx","./src/components/studio/editor/trackpropertyeditors.tsx","./src/components/studio/editor/treenodeitem.tsx","./src/components/studio/editor/edgestyles.ts","./src/components/studio/editor/editorkeyhandler.ts","./src/components/studio/editor/nodetyperegistry.ts","./src/components/studio/editor/palettecatalog.tsx","./src/components/studio/nodes/shell/interactionnodes.tsx","./src/components/studio/nodes/shell/layoutcontrolnodes.tsx","./src/components/studio/nodes/shell/registeractionnode.tsx","./src/components/studio/nodes/shell/registerbuttonnode.tsx","./src/components/studio/nodes/shell/registerpanelnode.tsx","./src/components/studio/nodes/shell/registersidebarnode.tsx","./src/components/studio/nodes/shell/registerstatusbarnode.tsx","./src/components/studio/nodes/shell/registertabnode.tsx","./src/components/studio/nodes/shell/registertopbarnode.tsx","./src/components/studio/nodes/shell/shellconfignode.tsx","./src/components/studio/nodes/shell/shellnodebase.tsx","./src/components/studio/nodes/shell/themenodes.tsx","./src/components/studio/nodes/shell/index.ts","./src/components/widgets/broadcastwidget.tsx","./src/components/widgets/marketplacewidget.tsx","./src/components/widgets/mcptoolswidget.tsx","./src/components/widgets/opsdashboard.tsx","./src/components/widgets/quickactionswidget.tsx","./src/components/widgets/usagewidget.tsx","./src/components/widgets/widgetrenderer.tsx","./src/components/widgets/widgetslotpanel.tsx","./src/config/iconregistry.ts","./src/contexts/networkprovider.tsx","./src/core/aidirector.ts","./src/core/eventbus.ts","./src/core/plugincontext.tsx","./src/hooks/morphbridge.ts","./src/hooks/useaimodelselector.ts","./src/hooks/useagentstream.ts","./src/hooks/useautoupdater.ts","./src/hooks/usebootsequence.ts","./src/hooks/useexportdsd.ts","./src/hooks/usefullscreen.ts","./src/hooks/usegeministream.ts","./src/hooks/useintentlens.ts","./src/hooks/usekeyboardshortcuts.ts","./src/hooks/useloggerbridge.ts","./src/hooks/usemcpclient.ts","./src/hooks/usenexusaideploy.ts","./src/hooks/useplaybackengine.ts","./src/hooks/useplaygroundcommander.ts","./src/hooks/usepluginengine.ts","./src/hooks/usescreenrecorder.ts","./src/hooks/useshellkeyboard.ts","./src/hooks/useshellshortcuts.ts","./src/hooks/usesoundeffects.ts","./src/hooks/usestudioconfig.ts","./src/hooks/usesystemboot.ts","./src/hooks/usesystemtelemetry.ts","./src/hooks/listeners/useuistatelistener.ts","./src/hooks/listeners/usewhatsapplistener.ts","./src/lib/debuglogger.ts","./src/lib/networkinterceptor.ts","./src/mocks/decido.tsx","./src/plugins/pluginapi.ts","./src/store/mcpstore.ts","./src/store/updaterstore.ts","./src/store/engine.ts","./src/store/index.ts","./src/store/layoutpresets.ts","./src/store/playgroundtypes.ts","./src/store/useactiontimelinestore.ts","./src/store/usedebugpanelstore.ts","./src/store/usedebugprofilestore.ts","./src/store/uselayoutstore.ts","./src/store/usemorphinstancestore.ts","./src/store/usemorphologystore.ts","./src/store/useplaygroundstore.ts","./src/store/useshellregistry.ts","./src/store/usesuggestionsstore.ts","./src/store/usethemestore.ts","./src/store/useuicomponentstore.ts","./src/types/decidostorydefinition.ts","./src/utils/layoutgraph.ts","./src/utils/ai/ai-architect.ts","./src/utils/ai/ai-code.ts","./src/utils/ai/ai-core.ts","./src/utils/ai/ai-media.ts"],"errors":true,"version":"5.9.3"}