@growgroup/visual-editor 0.1.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 (219) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +52 -0
  3. package/README.md +143 -0
  4. package/dist/editor.css +2 -0
  5. package/package.json +94 -0
  6. package/src/components/DeckSlideRender.tsx +21 -0
  7. package/src/components/SaveNote.tsx +21 -0
  8. package/src/components/auth/AuthProvider.tsx +44 -0
  9. package/src/components/ui/accordion.tsx +57 -0
  10. package/src/components/ui/alert-dialog.tsx +141 -0
  11. package/src/components/ui/badge.tsx +36 -0
  12. package/src/components/ui/button.tsx +56 -0
  13. package/src/components/ui/card.tsx +76 -0
  14. package/src/components/ui/checkbox.tsx +30 -0
  15. package/src/components/ui/collapsible.tsx +11 -0
  16. package/src/components/ui/context-menu.tsx +200 -0
  17. package/src/components/ui/dialog.tsx +122 -0
  18. package/src/components/ui/dropdown-menu.tsx +201 -0
  19. package/src/components/ui/input.tsx +22 -0
  20. package/src/components/ui/label.tsx +26 -0
  21. package/src/components/ui/popover.tsx +33 -0
  22. package/src/components/ui/scroll-area.tsx +48 -0
  23. package/src/components/ui/scrubbable-label.tsx +95 -0
  24. package/src/components/ui/select.tsx +159 -0
  25. package/src/components/ui/separator.tsx +31 -0
  26. package/src/components/ui/slider.tsx +28 -0
  27. package/src/components/ui/switch.tsx +29 -0
  28. package/src/components/ui/tabs.tsx +55 -0
  29. package/src/components/ui/textarea.tsx +22 -0
  30. package/src/components/ui/tooltip.tsx +32 -0
  31. package/src/components/viewer/useDeck.ts +58 -0
  32. package/src/editor/EditorContext.tsx +632 -0
  33. package/src/editor/EditorToolbar.tsx +446 -0
  34. package/src/editor/FrontendVisualEditor.tsx +2595 -0
  35. package/src/editor/autosave.ts +34 -0
  36. package/src/editor/components/AiPromptPopover.tsx +378 -0
  37. package/src/editor/components/BreakpointGuides.tsx +323 -0
  38. package/src/editor/components/BreakpointSelector.tsx +180 -0
  39. package/src/editor/components/ComponentPropertyEditor.tsx +426 -0
  40. package/src/editor/components/CssEditorDialog.tsx +168 -0
  41. package/src/editor/components/EditorCanvas.tsx +987 -0
  42. package/src/editor/components/EditorContextMenu.tsx +515 -0
  43. package/src/editor/components/EditorFooter.tsx +81 -0
  44. package/src/editor/components/EditorHeader.tsx +524 -0
  45. package/src/editor/components/EditorLayerPanel.tsx +1197 -0
  46. package/src/editor/components/EditorPropertyPanel.tsx +2996 -0
  47. package/src/editor/components/EditorSidebar.tsx +226 -0
  48. package/src/editor/components/FigmaColorPicker.tsx +1577 -0
  49. package/src/editor/components/HtmlEditorDialog.tsx +71 -0
  50. package/src/editor/components/HtmlImportDialog.tsx +346 -0
  51. package/src/editor/components/JsEditorDialog.tsx +175 -0
  52. package/src/editor/components/LayerTreeItem.tsx +494 -0
  53. package/src/editor/components/MasterComponentEditor.tsx +846 -0
  54. package/src/editor/components/MediaLibraryDialog.tsx +447 -0
  55. package/src/editor/components/PageSettingsDialog.tsx +776 -0
  56. package/src/editor/components/VariablePicker.tsx +355 -0
  57. package/src/editor/components/VariablesDialog.tsx +564 -0
  58. package/src/editor/components/VariantEditor.tsx +687 -0
  59. package/src/editor/components/VariantMatrix.tsx +507 -0
  60. package/src/editor/components/component-panel/CategoryAccordion.tsx +139 -0
  61. package/src/editor/components/component-panel/ComponentGrid.tsx +51 -0
  62. package/src/editor/components/component-panel/ComponentItem.tsx +368 -0
  63. package/src/editor/components/component-panel/ComponentPanel.tsx +275 -0
  64. package/src/editor/components/component-panel/ComponentSearch.tsx +82 -0
  65. package/src/editor/components/component-panel/VariantList.tsx +260 -0
  66. package/src/editor/components/component-panel/index.ts +12 -0
  67. package/src/editor/components/index.ts +48 -0
  68. package/src/editor/components/multi-page/CanvasZoomControls.tsx +71 -0
  69. package/src/editor/components/multi-page/InfiniteCanvas.tsx +95 -0
  70. package/src/editor/components/multi-page/MultiPageCanvasView.tsx +1404 -0
  71. package/src/editor/components/multi-page/PageFrameOverlay.tsx +76 -0
  72. package/src/editor/components/multi-page/PageLabel.tsx +34 -0
  73. package/src/editor/components/multi-page/PageLivePreview.tsx +242 -0
  74. package/src/editor/components/multi-page/PageThumbnail.tsx +59 -0
  75. package/src/editor/components/multi-page/index.ts +7 -0
  76. package/src/editor/components/ppt/PptChrome.tsx +2508 -0
  77. package/src/editor/components/ppt/PptComments.tsx +589 -0
  78. package/src/editor/components/ppt/PptDesignProposals.tsx +275 -0
  79. package/src/editor/components/ppt/PptFormatPane.tsx +320 -0
  80. package/src/editor/components/ppt/PptNotes.tsx +246 -0
  81. package/src/editor/components/property-panel/AlignmentPanel.tsx +110 -0
  82. package/src/editor/components/property-panel/AutoLayoutPanel.tsx +615 -0
  83. package/src/editor/components/property-panel/BorderSection.tsx +104 -0
  84. package/src/editor/components/property-panel/CompactNumberInput.tsx +237 -0
  85. package/src/editor/components/property-panel/CompactSizeInput.tsx +148 -0
  86. package/src/editor/components/property-panel/EffectSection.tsx +157 -0
  87. package/src/editor/components/property-panel/FillSection.tsx +69 -0
  88. package/src/editor/components/property-panel/GoogleFontPicker.tsx +192 -0
  89. package/src/editor/components/property-panel/ImageSection.tsx +206 -0
  90. package/src/editor/components/property-panel/ImgSrcSection.tsx +125 -0
  91. package/src/editor/components/property-panel/InstanceOverrideSection.tsx +413 -0
  92. package/src/editor/components/property-panel/LayoutSection.tsx +105 -0
  93. package/src/editor/components/property-panel/LinkSection.tsx +103 -0
  94. package/src/editor/components/property-panel/PropertyVariablePicker.tsx +311 -0
  95. package/src/editor/components/property-panel/ScalePanel.tsx +212 -0
  96. package/src/editor/components/property-panel/TypographySection.tsx +230 -0
  97. package/src/editor/components/property-panel/UnitAwareNumberInput.tsx +238 -0
  98. package/src/editor/components/property-panel/VariableAwareColorInput.tsx +477 -0
  99. package/src/editor/components/property-panel/VariableAwareInput.tsx +606 -0
  100. package/src/editor/components/property-panel/VariableAwareSizeInput.tsx +588 -0
  101. package/src/editor/components/property-panel/VariableAwareUnitInput.tsx +546 -0
  102. package/src/editor/components/property-panel/index.ts +24 -0
  103. package/src/editor/components/property-panel/unit-utils.ts +261 -0
  104. package/src/editor/components/shell/EditorTopBar.tsx +392 -0
  105. package/src/editor/components/shell/LeftPanel.tsx +47 -0
  106. package/src/editor/components/shell/PagesPanel.tsx +118 -0
  107. package/src/editor/components/variables-panel/ColorValueCell.tsx +165 -0
  108. package/src/editor/components/variables-panel/TextValueCell.tsx +116 -0
  109. package/src/editor/components/variables-panel/VariablesPanel.tsx +518 -0
  110. package/src/editor/components/variables-panel/index.ts +7 -0
  111. package/src/editor/constants.ts +468 -0
  112. package/src/editor/contexts/EditorArtboardContext.tsx +229 -0
  113. package/src/editor/contexts/EditorComponentsContext.tsx +1320 -0
  114. package/src/editor/contexts/EditorDocumentContext.tsx +113 -0
  115. package/src/editor/contexts/EditorHistoryContext.tsx +516 -0
  116. package/src/editor/contexts/EditorRefsContext.tsx +204 -0
  117. package/src/editor/contexts/EditorSelectionContext.tsx +54 -0
  118. package/src/editor/contexts/EditorToolContext.tsx +58 -0
  119. package/src/editor/contexts/EditorUIStateContext.tsx +122 -0
  120. package/src/editor/contexts/EditorVariablesContext.tsx +397 -0
  121. package/src/editor/contexts/EditorViewContext.tsx +101 -0
  122. package/src/editor/contexts/MultiPageCanvasContext.tsx +498 -0
  123. package/src/editor/contexts/index.ts +17 -0
  124. package/src/editor/editor-skin.css +122 -0
  125. package/src/editor/hooks/index.ts +38 -0
  126. package/src/editor/hooks/useAiReplace.ts +397 -0
  127. package/src/editor/hooks/useAltMeasure.ts +67 -0
  128. package/src/editor/hooks/useBrowserZoomPrevention.ts +121 -0
  129. package/src/editor/hooks/useCanvasControls.ts +1222 -0
  130. package/src/editor/hooks/useComponentEditMode.ts +658 -0
  131. package/src/editor/hooks/useComponentInstances.ts +515 -0
  132. package/src/editor/hooks/useContextMenuHandler.ts +157 -0
  133. package/src/editor/hooks/useCoordinateTransform.ts +207 -0
  134. package/src/editor/hooks/useDragResize.ts +1317 -0
  135. package/src/editor/hooks/useDrawingMode.ts +472 -0
  136. package/src/editor/hooks/useEditorColors.ts +144 -0
  137. package/src/editor/hooks/useEditorMessages.ts +108 -0
  138. package/src/editor/hooks/useElementActions.ts +1754 -0
  139. package/src/editor/hooks/useElementSelection.ts +1573 -0
  140. package/src/editor/hooks/useFocusManagement.ts +249 -0
  141. package/src/editor/hooks/useGoogleFonts.ts +305 -0
  142. package/src/editor/hooks/useIframeInitializer.ts +584 -0
  143. package/src/editor/hooks/useIframeSetup.ts +360 -0
  144. package/src/editor/hooks/useImageUpload.ts +270 -0
  145. package/src/editor/hooks/useInfiniteCanvas.ts +301 -0
  146. package/src/editor/hooks/useKeyboardShortcuts.ts +205 -0
  147. package/src/editor/hooks/useMarqueeSelection.ts +388 -0
  148. package/src/editor/hooks/useMediaLibrary.ts +129 -0
  149. package/src/editor/hooks/usePageSettingsManager.ts +739 -0
  150. package/src/editor/hooks/useResizablePanel.ts +163 -0
  151. package/src/editor/hooks/useRichPaste.ts +255 -0
  152. package/src/editor/hooks/useTouchGestures.ts +197 -0
  153. package/src/editor/index.ts +27 -0
  154. package/src/editor/types/page-settings.ts +513 -0
  155. package/src/editor/types.ts +382 -0
  156. package/src/editor/utils/align-elements.ts +169 -0
  157. package/src/editor/utils/api-json.ts +21 -0
  158. package/src/editor/utils/aspect-lock.ts +50 -0
  159. package/src/editor/utils/component-renderer.ts +702 -0
  160. package/src/editor/utils/component-sync.ts +845 -0
  161. package/src/editor/utils/crop-mode.ts +265 -0
  162. package/src/editor/utils/dom-utils.ts +2238 -0
  163. package/src/editor/utils/element-effects.ts +218 -0
  164. package/src/editor/utils/eyedropper.ts +35 -0
  165. package/src/editor/utils/figma-export.ts +560 -0
  166. package/src/editor/utils/figma-kiwi-decoder.ts +722 -0
  167. package/src/editor/utils/figma-kiwi-encoder.ts +583 -0
  168. package/src/editor/utils/figma-paste.ts +2262 -0
  169. package/src/editor/utils/flex-reorder.ts +231 -0
  170. package/src/editor/utils/flex-utils.ts +1230 -0
  171. package/src/editor/utils/geometry.ts +232 -0
  172. package/src/editor/utils/grid-layout.ts +210 -0
  173. package/src/editor/utils/html-utils.ts +470 -0
  174. package/src/editor/utils/index.ts +11 -0
  175. package/src/editor/utils/ink-style.ts +57 -0
  176. package/src/editor/utils/inline-format.ts +236 -0
  177. package/src/editor/utils/measure-distance.ts +120 -0
  178. package/src/editor/utils/override-apply.ts +526 -0
  179. package/src/editor/utils/override-detection.ts +613 -0
  180. package/src/editor/utils/paste-processors.ts +609 -0
  181. package/src/editor/utils/paste-sanitizer.ts +244 -0
  182. package/src/editor/utils/restore-flow.ts +188 -0
  183. package/src/editor/utils/shape-library.ts +171 -0
  184. package/src/editor/utils/slide-root.ts +29 -0
  185. package/src/editor/utils/smart-guides.ts +218 -0
  186. package/src/editor/utils/style-utils.ts +685 -0
  187. package/src/editor/utils/table-edit.ts +151 -0
  188. package/src/editor/utils/tailwind-mappings.ts +778 -0
  189. package/src/editor/utils/tailwind-utils.ts +804 -0
  190. package/src/editor/utils/text-highlight.ts +216 -0
  191. package/src/editor/utils/theme-to-variables.ts +341 -0
  192. package/src/editor/utils/variant-resolver.ts +456 -0
  193. package/src/editor/utils/viewport-utils.ts +295 -0
  194. package/src/hooks/useEditorHistory.ts +195 -0
  195. package/src/hooks/useEditorShortcuts.ts +260 -0
  196. package/src/index.ts +40 -0
  197. package/src/io.ts +134 -0
  198. package/src/lib/agent/slide-agent/types.ts +547 -0
  199. package/src/lib/agent/website-agent/types.ts +805 -0
  200. package/src/lib/api/auth-fetch.ts +58 -0
  201. package/src/lib/deck.ts +69 -0
  202. package/src/lib/export.ts +47 -0
  203. package/src/lib/firebase/config.ts +29 -0
  204. package/src/lib/firebase/css-variables.ts +378 -0
  205. package/src/lib/firebase/editor-components.ts +677 -0
  206. package/src/lib/firebase/storage.ts +469 -0
  207. package/src/lib/utils.ts +6 -0
  208. package/src/styles/editor.css +52 -0
  209. package/src/styles/skin.css +122 -0
  210. package/src/types/css-variables.ts +645 -0
  211. package/src/types/editor-components.ts +944 -0
  212. package/src/types/editor.ts +420 -0
  213. package/src/types/page-master.ts +197 -0
  214. package/src/types/page.ts +419 -0
  215. package/src/types/slide.ts +402 -0
  216. package/src/types/website-theme.ts +788 -0
  217. package/src/types/website.ts +374 -0
  218. package/src/vendor/firebase-firestore.ts +13 -0
  219. package/src/vendor/firebase-functions.ts +17 -0
@@ -0,0 +1,547 @@
1
+ /**
2
+ * Slide Agent 型定義
3
+ *
4
+ * Interactions API を使用したスライド生成エージェントの型定義
5
+ */
6
+
7
+ import type { SlidePresentationPlan, SlideGenerationResult, SlideMaster, Slide, DesignFlexibility } from '../../../types/slide';
8
+ /** 移植時にローカル定義へ置換(オリジナルは @/lib/ai/gemini-presentaion) */
9
+ type ThemeDetails = Record<string, unknown>;
10
+
11
+ // Re-export types used by other modules
12
+ export type { SlidePresentationPlan, SlideGenerationResult, SlideMaster, Slide, ThemeDetails, DesignFlexibility };
13
+
14
+ // =====================
15
+ // Interactions API 型
16
+ // =====================
17
+
18
+ /**
19
+ * ツール定義
20
+ */
21
+ export interface SlideAgentTool {
22
+ type: 'function';
23
+ name: string;
24
+ description: string;
25
+ parameters: {
26
+ type: 'object';
27
+ properties: Record<string, ToolParameter>;
28
+ required?: string[];
29
+ };
30
+ }
31
+
32
+ export interface ToolParameter {
33
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object';
34
+ description?: string;
35
+ enum?: string[];
36
+ items?: ToolParameter;
37
+ properties?: Record<string, ToolParameter>;
38
+ required?: string[];
39
+ }
40
+
41
+ /**
42
+ * インタラクションオプション
43
+ */
44
+ export interface InteractionOptions {
45
+ model?: string;
46
+ previousInteractionId?: string;
47
+ stream?: boolean;
48
+ systemInstruction?: string;
49
+ generationConfig?: {
50
+ temperature?: number;
51
+ maxOutputTokens?: number;
52
+ thinkingLevel?: 'minimal' | 'low' | 'medium' | 'high';
53
+ thinkingSummaries?: 'auto' | 'none';
54
+ };
55
+ store?: boolean;
56
+ }
57
+
58
+ /**
59
+ * インタラクション出力
60
+ */
61
+ export type InteractionOutput =
62
+ | TextOutput
63
+ | ThoughtOutput
64
+ | ToolCallOutput
65
+ | ToolResultOutput;
66
+
67
+ export interface TextOutput {
68
+ type: 'text';
69
+ text: string;
70
+ }
71
+
72
+ export interface ThoughtOutput {
73
+ type: 'thought';
74
+ summary?: string;
75
+ signature: string;
76
+ }
77
+
78
+ export interface ToolCallOutput {
79
+ type: 'function_call';
80
+ id: string;
81
+ name: string;
82
+ arguments: Record<string, unknown>;
83
+ }
84
+
85
+ export interface ToolResultOutput {
86
+ type: 'function_result';
87
+ name: string;
88
+ call_id: string;
89
+ result: unknown;
90
+ }
91
+
92
+ /**
93
+ * インタラクション結果
94
+ */
95
+ export interface InteractionResult {
96
+ id: string;
97
+ status: 'completed' | 'in_progress' | 'requires_action' | 'failed' | 'cancelled';
98
+ outputs: InteractionOutput[];
99
+ usage?: {
100
+ input_tokens: number;
101
+ output_tokens: number;
102
+ total_tokens: number;
103
+ };
104
+ }
105
+
106
+ // =====================
107
+ // ツール引数型
108
+ // =====================
109
+
110
+ /**
111
+ * generate_slide_plan ツール引数
112
+ */
113
+ export interface GeneratePlanArgs {
114
+ prompt: string;
115
+ slideCount?: number;
116
+ theme?: 'light' | 'dark' | 'corporate' | 'modern';
117
+ primaryColor?: string;
118
+ attachedFiles?: Array<{
119
+ name: string;
120
+ type: string;
121
+ data: string; // base64
122
+ }>;
123
+ }
124
+
125
+ /**
126
+ * generate_slide_html ツール引数
127
+ */
128
+ export interface GenerateSlideHtmlArgs {
129
+ slideIndex: number;
130
+ plan: SlidePresentationPlan;
131
+ slideMasterId?: string;
132
+ theme?: string;
133
+ primaryColor?: string;
134
+ slideHeightMode?: 'fixed' | 'auto';
135
+ }
136
+
137
+ /**
138
+ * search_slide_masters ツール引数
139
+ */
140
+ export interface SearchSlideMastersArgs {
141
+ query?: string;
142
+ category?: SlideMaster['category'];
143
+ limit?: number;
144
+ }
145
+
146
+ /**
147
+ * get_slide_master ツール引数
148
+ */
149
+ export interface GetSlideMasterArgs {
150
+ masterId: string;
151
+ }
152
+
153
+ /**
154
+ * save_slide ツール引数
155
+ */
156
+ export interface SaveSlideArgs {
157
+ presentationId: string;
158
+ slideData: {
159
+ title: string;
160
+ slideNumber: number;
161
+ html: string;
162
+ css?: string;
163
+ notes?: string;
164
+ category?: string;
165
+ slideMasterId?: string;
166
+ };
167
+ }
168
+
169
+ /**
170
+ * update_slide ツール引数
171
+ */
172
+ export interface UpdateSlideArgs {
173
+ presentationId: string;
174
+ slideId: string;
175
+ updates: Partial<{
176
+ title: string;
177
+ content: Slide['content'];
178
+ generatedHtml: string;
179
+ }>;
180
+ }
181
+
182
+ /**
183
+ * google_search ツール引数
184
+ */
185
+ export interface GoogleSearchArgs {
186
+ query: string;
187
+ maxResults?: number;
188
+ }
189
+
190
+ /**
191
+ * generate_image ツール引数
192
+ */
193
+ export interface GenerateImageArgs {
194
+ prompt: string;
195
+ style?: 'realistic' | 'illustration' | 'icon' | 'diagram' | 'flat' | 'minimal';
196
+ aspectRatio?: '1:1' | '16:9' | '4:3' | '3:4' | '9:16';
197
+ backgroundColor?: string;
198
+ }
199
+
200
+ /**
201
+ * fetch_page ツール引数
202
+ */
203
+ export interface FetchPageArgs {
204
+ url: string;
205
+ extractText?: boolean;
206
+ }
207
+
208
+ // =====================
209
+ // ツール結果型
210
+ // =====================
211
+
212
+ export interface GeneratePlanResult {
213
+ success: boolean;
214
+ plan?: SlidePresentationPlan;
215
+ error?: string;
216
+ }
217
+
218
+ export interface GenerateSlideHtmlResult {
219
+ success: boolean;
220
+ slide?: SlideGenerationResult;
221
+ error?: string;
222
+ // 自動生成された画像情報
223
+ generatedImage?: {
224
+ dataUri: string;
225
+ description?: string;
226
+ };
227
+ }
228
+
229
+ export interface SearchSlideMastersResult {
230
+ success: boolean;
231
+ masters?: Array<{
232
+ id: string;
233
+ name: string;
234
+ description: string;
235
+ category: string;
236
+ thumbnail?: string;
237
+ }>;
238
+ error?: string;
239
+ }
240
+
241
+ export interface GetSlideMasterResult {
242
+ success: boolean;
243
+ master?: SlideMaster;
244
+ error?: string;
245
+ }
246
+
247
+ export interface SaveSlideResult {
248
+ success: boolean;
249
+ slideId?: string;
250
+ error?: string;
251
+ }
252
+
253
+ export interface UpdateSlideResult {
254
+ success: boolean;
255
+ error?: string;
256
+ }
257
+
258
+ export interface GoogleSearchResult {
259
+ success: boolean;
260
+ results?: Array<{
261
+ title: string;
262
+ url: string;
263
+ snippet: string;
264
+ }>;
265
+ error?: string;
266
+ }
267
+
268
+ export interface GenerateImageResult {
269
+ success: boolean;
270
+ imageUrl?: string; // data URI形式の画像(内部用)
271
+ imageId?: string; // 画像ID(キャッシュ参照用)
272
+ message?: string; // メッセージ
273
+ error?: string;
274
+ }
275
+
276
+ export interface FetchPageResult {
277
+ success: boolean;
278
+ content?: string;
279
+ title?: string;
280
+ error?: string;
281
+ }
282
+
283
+ // =====================
284
+ // エージェントモード
285
+ // =====================
286
+
287
+ /**
288
+ * エージェント実行モード
289
+ * - plan: 計画のみ生成(generate_slide_planのみ使用)
290
+ * - generate: スライド生成(generate_slide_html, save_slide等を使用)
291
+ * - generate_single: 単一スライド生成(1スライド=1インタラクション)
292
+ * - full: 計画からスライド生成まで一括実行
293
+ * - element_replace: 要素置換(選択要素をAI生成HTMLで置換)
294
+ */
295
+ export type SlideAgentMode = 'plan' | 'generate' | 'generate_single' | 'full' | 'element_replace';
296
+
297
+ // =====================
298
+ // 要素置換(element_replace)関連
299
+ // =====================
300
+
301
+ /**
302
+ * 添付ファイル型
303
+ */
304
+ export interface AttachedFile {
305
+ name: string;
306
+ type: string; // MIME type (e.g., 'image/png', 'application/pdf')
307
+ size: number;
308
+ data: string; // Base64 encoded data
309
+ }
310
+
311
+ /**
312
+ * generate_element_html ツール引数
313
+ */
314
+ export interface GenerateElementHtmlArgs {
315
+ prompt: string; // ユーザーのプロンプト
316
+ slideHtml: string; // 現在のスライド全体HTML
317
+ selectedElementHtml: string; // 選択中の要素HTML
318
+ selectedElementInfo: { // 要素のメタ情報
319
+ tagName: string;
320
+ width: number;
321
+ height: number;
322
+ position: { x: number; y: number };
323
+ };
324
+ imageId?: string; // 使用する画像ID(generate_imageで生成した場合)
325
+ attachedFiles?: AttachedFile[]; // 添付ファイル(画像、PDF等)
326
+ }
327
+
328
+ /**
329
+ * generate_element_html ツール結果
330
+ */
331
+ export interface GenerateElementHtmlResult {
332
+ success: boolean;
333
+ html?: string; // 生成されたHTML
334
+ explanation?: string; // 生成内容の説明
335
+ error?: string;
336
+ }
337
+
338
+ // =====================
339
+ // 画像キャッシュ
340
+ // =====================
341
+
342
+ /**
343
+ * 生成された画像のキャッシュエントリ
344
+ * Firebase Storageにアップロードされた画像のメタデータを保持
345
+ */
346
+ export interface GeneratedImageCache {
347
+ imageId: string;
348
+ storageUrl: string; // Firebase StorageのURL
349
+ storagePath?: string; // Storage内のパス
350
+ prompt: string;
351
+ style?: string;
352
+ createdAt: number;
353
+ }
354
+
355
+ // =====================
356
+ // エージェントコンテキスト
357
+ // =====================
358
+
359
+ /**
360
+ * テーマ詳細情報
361
+ * Note: ThemeDetails は gemini-presentaion.ts からインポート・再エクスポートされています
362
+ */
363
+ export type ThemeDetailsContext = ThemeDetails;
364
+
365
+ /**
366
+ * スライドエージェントのコンテキスト
367
+ */
368
+ export interface SlideAgentContext {
369
+ userId: string;
370
+ presentationId?: string;
371
+ modelName?: string;
372
+ originalPrompt?: string; // ユーザーの元のプロンプト(スライド生成時に使用)
373
+ currentPlan?: SlidePresentationPlan;
374
+ generatedSlides?: SlideGenerationResult[];
375
+ // 画像キャッシュ(generate_imageの結果を内部保持)
376
+ generatedImages?: Map<string, GeneratedImageCache>;
377
+ latestImageId?: string;
378
+ // テーマ関連
379
+ theme?: string;
380
+ themeDetails?: ThemeDetailsContext;
381
+ primaryColor?: string;
382
+ slideHeightMode?: 'fixed' | 'auto';
383
+ slideMasterId?: string;
384
+ /** デザイン自由度設定(デフォルト: standard) */
385
+ designFlexibility?: DesignFlexibility;
386
+ // 要素置換用コンテキスト
387
+ elementReplaceContext?: {
388
+ slideHtml: string;
389
+ selectedElementHtml: string;
390
+ selectedElementInfo: {
391
+ tagName: string;
392
+ width: number;
393
+ height: number;
394
+ position: { x: number; y: number };
395
+ };
396
+ };
397
+ }
398
+
399
+ /**
400
+ * ツールハンドラー
401
+ */
402
+ export type ToolHandler<TArgs = unknown, TResult = unknown> = (
403
+ args: TArgs,
404
+ context: SlideAgentContext
405
+ ) => Promise<TResult>;
406
+
407
+ /**
408
+ * ツールレジストリ
409
+ */
410
+ export interface ToolRegistry {
411
+ tools: SlideAgentTool[];
412
+ handlers: Map<string, ToolHandler>;
413
+ }
414
+
415
+ // =====================
416
+ // SSE ストリーミング型
417
+ // =====================
418
+
419
+ export interface SSEEvent {
420
+ type: 'status' | 'progress' | 'tool_call' | 'tool_result' | 'text' | 'error' | 'complete';
421
+ data: unknown;
422
+ }
423
+
424
+ export interface SSEStatusEvent extends SSEEvent {
425
+ type: 'status';
426
+ data: {
427
+ stage: 'initializing' | 'planning' | 'generating' | 'saving' | 'complete' | 'error';
428
+ message: string;
429
+ };
430
+ }
431
+
432
+ export interface SSEProgressEvent extends SSEEvent {
433
+ type: 'progress';
434
+ data: {
435
+ current: number;
436
+ total: number;
437
+ message: string;
438
+ };
439
+ }
440
+
441
+ export interface SSEToolCallEvent extends SSEEvent {
442
+ type: 'tool_call';
443
+ data: {
444
+ name: string;
445
+ arguments: Record<string, unknown>;
446
+ };
447
+ }
448
+
449
+ export interface SSEToolResultEvent extends SSEEvent {
450
+ type: 'tool_result';
451
+ data: {
452
+ name: string;
453
+ success: boolean;
454
+ result?: unknown;
455
+ error?: string;
456
+ };
457
+ }
458
+
459
+ export interface SSETextEvent extends SSEEvent {
460
+ type: 'text';
461
+ data: {
462
+ text: string;
463
+ isPartial?: boolean;
464
+ };
465
+ }
466
+
467
+ export interface SSEErrorEvent extends SSEEvent {
468
+ type: 'error';
469
+ data: {
470
+ message: string;
471
+ code?: string;
472
+ };
473
+ }
474
+
475
+ export interface SSECompleteEvent extends SSEEvent {
476
+ type: 'complete';
477
+ data: {
478
+ plan?: SlidePresentationPlan;
479
+ slides?: SlideGenerationResult[];
480
+ message: string;
481
+ };
482
+ }
483
+
484
+ // =====================
485
+ // API リクエスト/レスポンス
486
+ // =====================
487
+
488
+ /**
489
+ * スライドエージェント API リクエスト
490
+ */
491
+ export interface SlideAgentRequest {
492
+ prompt: string;
493
+ presentationId?: string; // element_replaceモードではオプショナル
494
+ userId: string;
495
+ options?: {
496
+ /** エージェント実行モード(plan: 計画のみ, generate: スライド生成, generate_single: 単一スライド, full: 一括, element_replace: 要素置換) */
497
+ mode?: SlideAgentMode;
498
+ /** 生成するスライドのインデックス(generate_singleモード時に必須、0から開始) */
499
+ slideIndex?: number;
500
+ slideCount?: number;
501
+ theme?: 'light' | 'dark' | 'corporate' | 'modern';
502
+ /** テーマ詳細(色、タイポグラフィ、レイアウト設定) */
503
+ themeDetails?: ThemeDetails;
504
+ primaryColor?: string;
505
+ slideMasterId?: string;
506
+ presentationMasterId?: string;
507
+ modelName?: string;
508
+ slideHeightMode?: 'fixed' | 'auto';
509
+ /** デザイン自由度設定(strict: テンプレート厳守, standard: 推奨, creative: 自由) */
510
+ designFlexibility?: DesignFlexibility;
511
+ attachedFiles?: Array<{
512
+ name: string;
513
+ type: string;
514
+ size: number;
515
+ data: string;
516
+ }>;
517
+ stream?: boolean;
518
+ /** 既存の計画(generate/generate_singleモード時に使用) */
519
+ existingPlan?: SlidePresentationPlan;
520
+ /** 要素置換用オプション(element_replaceモード時に使用) */
521
+ elementReplace?: {
522
+ slideHtml: string;
523
+ selectedElementHtml: string;
524
+ selectedElementInfo: {
525
+ tagName: string;
526
+ width: number;
527
+ height: number;
528
+ position: { x: number; y: number };
529
+ };
530
+ attachedFiles?: AttachedFile[]; // 添付ファイル(画像、PDF等)
531
+ };
532
+ };
533
+ }
534
+
535
+ /**
536
+ * スライドエージェント API レスポンス
537
+ */
538
+ export interface SlideAgentResponse {
539
+ success: boolean;
540
+ interactionId?: string;
541
+ plan?: SlidePresentationPlan;
542
+ slides?: SlideGenerationResult[];
543
+ /** 要素置換モード用: 生成されたHTML */
544
+ generatedHtml?: string;
545
+ message?: string;
546
+ error?: string;
547
+ }