@d34dman/flowdrop 0.0.29 → 0.0.31

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 (55) hide show
  1. package/dist/components/App.svelte +54 -6
  2. package/dist/components/NodeSidebar.svelte +17 -9
  3. package/dist/components/SchemaForm.svelte +14 -14
  4. package/dist/components/SchemaForm.svelte.d.ts +1 -1
  5. package/dist/components/WorkflowEditor.svelte +4 -0
  6. package/dist/components/form/FormFieldLight.svelte +66 -66
  7. package/dist/components/form/FormFieldLight.svelte.d.ts +1 -1
  8. package/dist/components/form/types.d.ts +1 -1
  9. package/dist/components/nodes/ToolNode.svelte +23 -8
  10. package/dist/components/playground/ChatPanel.svelte +523 -0
  11. package/dist/components/playground/ChatPanel.svelte.d.ts +20 -0
  12. package/dist/components/playground/ExecutionLogs.svelte +486 -0
  13. package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
  14. package/dist/components/playground/InputCollector.svelte +444 -0
  15. package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
  16. package/dist/components/playground/MessageBubble.svelte +398 -0
  17. package/dist/components/playground/MessageBubble.svelte.d.ts +15 -0
  18. package/dist/components/playground/Playground.svelte +851 -0
  19. package/dist/components/playground/Playground.svelte.d.ts +25 -0
  20. package/dist/components/playground/SessionManager.svelte +537 -0
  21. package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
  22. package/dist/config/endpoints.d.ts +16 -0
  23. package/dist/config/endpoints.js +9 -0
  24. package/dist/core/index.d.ts +25 -23
  25. package/dist/core/index.js +13 -12
  26. package/dist/display/index.d.ts +2 -2
  27. package/dist/display/index.js +2 -2
  28. package/dist/editor/index.d.ts +57 -49
  29. package/dist/editor/index.js +52 -42
  30. package/dist/form/code.d.ts +4 -4
  31. package/dist/form/code.js +11 -11
  32. package/dist/form/fieldRegistry.d.ts +2 -2
  33. package/dist/form/fieldRegistry.js +8 -10
  34. package/dist/form/full.d.ts +5 -5
  35. package/dist/form/full.js +7 -7
  36. package/dist/form/index.d.ts +16 -16
  37. package/dist/form/index.js +14 -14
  38. package/dist/form/markdown.d.ts +3 -3
  39. package/dist/form/markdown.js +6 -6
  40. package/dist/index.d.ts +6 -4
  41. package/dist/index.js +9 -4
  42. package/dist/playground/index.d.ts +92 -0
  43. package/dist/playground/index.js +114 -0
  44. package/dist/playground/mount.d.ts +183 -0
  45. package/dist/playground/mount.js +178 -0
  46. package/dist/services/playgroundService.d.ts +129 -0
  47. package/dist/services/playgroundService.js +317 -0
  48. package/dist/stores/playgroundStore.d.ts +199 -0
  49. package/dist/stores/playgroundStore.js +350 -0
  50. package/dist/styles/base.css +5 -0
  51. package/dist/types/playground.d.ts +230 -0
  52. package/dist/types/playground.js +28 -0
  53. package/dist/utils/colors.d.ts +42 -0
  54. package/dist/utils/colors.js +77 -0
  55. package/package.json +6 -1
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Playground Types
3
+ *
4
+ * TypeScript types for the Playground feature, enabling interactive
5
+ * workflow testing with chat interface and session management.
6
+ *
7
+ * @module types/playground
8
+ */
9
+ import type { ConfigProperty } from './index.js';
10
+ /**
11
+ * Status of a playground session
12
+ */
13
+ export type PlaygroundSessionStatus = 'idle' | 'running' | 'completed' | 'failed';
14
+ /**
15
+ * Role of a message sender in the playground
16
+ *
17
+ * - `user`: Message from the user
18
+ * - `assistant`: Response from the workflow/AI
19
+ * - `system`: System notifications
20
+ * - `log`: Execution log entries
21
+ */
22
+ export type PlaygroundMessageRole = 'user' | 'assistant' | 'system' | 'log';
23
+ /**
24
+ * Log level for log-type messages
25
+ */
26
+ export type PlaygroundMessageLevel = 'info' | 'warning' | 'error' | 'debug';
27
+ /**
28
+ * Playground session representing a test conversation
29
+ *
30
+ * Sessions maintain conversation history and allow interactive testing
31
+ * of workflows in an isolated environment.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const session: PlaygroundSession = {
36
+ * id: "sess-123",
37
+ * workflowId: "wf-456",
38
+ * name: "Test Session 1",
39
+ * status: "idle",
40
+ * createdAt: "2024-01-20T10:00:00Z",
41
+ * updatedAt: "2024-01-20T10:30:00Z"
42
+ * };
43
+ * ```
44
+ */
45
+ export interface PlaygroundSession {
46
+ /** Session unique identifier */
47
+ id: string;
48
+ /** Associated workflow ID */
49
+ workflowId: string;
50
+ /** Session display name */
51
+ name: string;
52
+ /** Current session status */
53
+ status: PlaygroundSessionStatus;
54
+ /** Session creation timestamp (ISO 8601) */
55
+ createdAt: string;
56
+ /** Last activity timestamp (ISO 8601) */
57
+ updatedAt: string;
58
+ /** Custom session metadata */
59
+ metadata?: Record<string, unknown>;
60
+ }
61
+ /**
62
+ * Message metadata containing additional context
63
+ */
64
+ export interface PlaygroundMessageMetadata {
65
+ /** Log level for log-type messages */
66
+ level?: PlaygroundMessageLevel;
67
+ /** Execution duration in milliseconds */
68
+ duration?: number;
69
+ /** Human-readable node label */
70
+ nodeLabel?: string;
71
+ /** Node output data */
72
+ outputs?: Record<string, unknown>;
73
+ /** Allow additional properties */
74
+ [key: string]: unknown;
75
+ }
76
+ /**
77
+ * Message in a playground session
78
+ *
79
+ * Messages can be user inputs, assistant responses, system notifications,
80
+ * or execution logs. Each message is timestamped and can be associated
81
+ * with a specific workflow node.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const message: PlaygroundMessage = {
86
+ * id: "msg-123",
87
+ * sessionId: "sess-456",
88
+ * role: "assistant",
89
+ * content: "I've analyzed your data and found 3 patterns.",
90
+ * timestamp: "2024-01-20T10:30:00Z",
91
+ * nodeId: "node-ai-analyzer",
92
+ * metadata: { duration: 2500, nodeLabel: "AI Analyzer" }
93
+ * };
94
+ * ```
95
+ */
96
+ export interface PlaygroundMessage {
97
+ /** Message unique identifier */
98
+ id: string;
99
+ /** Parent session ID */
100
+ sessionId: string;
101
+ /** Role of the message sender */
102
+ role: PlaygroundMessageRole;
103
+ /** Message content */
104
+ content: string;
105
+ /** Message timestamp (ISO 8601) */
106
+ timestamp: string;
107
+ /** Associated node ID (for log messages) */
108
+ nodeId?: string;
109
+ /** Additional message metadata */
110
+ metadata?: PlaygroundMessageMetadata;
111
+ }
112
+ /**
113
+ * Input field derived from workflow input nodes
114
+ *
115
+ * Used to auto-generate input forms in the playground based on
116
+ * the workflow's input nodes' configSchema.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const inputField: PlaygroundInputField = {
121
+ * nodeId: "node-text-input",
122
+ * fieldId: "user_message",
123
+ * label: "User Message",
124
+ * type: "string",
125
+ * defaultValue: "Hello!",
126
+ * required: true,
127
+ * schema: { type: "string", format: "multiline" }
128
+ * };
129
+ * ```
130
+ */
131
+ export interface PlaygroundInputField {
132
+ /** Source node ID */
133
+ nodeId: string;
134
+ /** Field identifier */
135
+ fieldId: string;
136
+ /** Display label */
137
+ label: string;
138
+ /** Field data type */
139
+ type: string;
140
+ /** Default value from node config */
141
+ defaultValue?: unknown;
142
+ /** Whether the field is required */
143
+ required: boolean;
144
+ /** JSON Schema for the field */
145
+ schema?: ConfigProperty;
146
+ }
147
+ /**
148
+ * Request payload for sending a message to the playground
149
+ */
150
+ export interface PlaygroundMessageRequest {
151
+ /** Message content (typically user input) */
152
+ content: string;
153
+ /** Additional input values for workflow nodes */
154
+ inputs?: Record<string, unknown>;
155
+ }
156
+ /**
157
+ * Response from the messages endpoint with polling support
158
+ */
159
+ export interface PlaygroundMessagesResult {
160
+ /** Array of messages */
161
+ messages: PlaygroundMessage[];
162
+ /** Whether there are more messages to fetch */
163
+ hasMore: boolean;
164
+ /** Current session status (useful for polling) */
165
+ sessionStatus: PlaygroundSessionStatus;
166
+ }
167
+ /**
168
+ * Configuration for the Playground component
169
+ */
170
+ export interface PlaygroundConfig {
171
+ /** Polling interval in milliseconds (default: 1500) */
172
+ pollingInterval?: number;
173
+ /** Maximum number of messages to display (default: 500) */
174
+ maxMessages?: number;
175
+ /** Auto-scroll to bottom on new messages (default: true) */
176
+ autoScroll?: boolean;
177
+ /** Show timestamps on messages (default: true) */
178
+ showTimestamps?: boolean;
179
+ /** Show log messages inline or in collapsible section (default: "collapsible") */
180
+ logDisplayMode?: 'inline' | 'collapsible';
181
+ }
182
+ /**
183
+ * Display mode for the Playground component
184
+ */
185
+ export type PlaygroundMode = 'embedded' | 'standalone';
186
+ /**
187
+ * Chat input detection patterns for identifying chat nodes in workflows
188
+ */
189
+ export declare const CHAT_INPUT_PATTERNS: readonly ["chat_input", "text_input", "user_input", "message_input", "prompt_input"];
190
+ /**
191
+ * Check if a node type is a chat input node
192
+ *
193
+ * @param nodeTypeId - The node type identifier
194
+ * @returns True if the node is a chat input type
195
+ */
196
+ export declare function isChatInputNode(nodeTypeId: string): boolean;
197
+ /**
198
+ * API response wrapper for playground endpoints
199
+ */
200
+ export interface PlaygroundApiResponse<T> {
201
+ /** Whether the request was successful */
202
+ success: boolean;
203
+ /** Response data */
204
+ data?: T;
205
+ /** Error message if unsuccessful */
206
+ error?: string;
207
+ /** Human-readable message */
208
+ message?: string;
209
+ }
210
+ /**
211
+ * Type alias for session list response
212
+ */
213
+ export type PlaygroundSessionsResponse = PlaygroundApiResponse<PlaygroundSession[]>;
214
+ /**
215
+ * Type alias for single session response
216
+ */
217
+ export type PlaygroundSessionResponse = PlaygroundApiResponse<PlaygroundSession>;
218
+ /**
219
+ * Type alias for message response
220
+ */
221
+ export type PlaygroundMessageResponse = PlaygroundApiResponse<PlaygroundMessage>;
222
+ /**
223
+ * Type alias for messages list response with polling metadata
224
+ */
225
+ export interface PlaygroundMessagesApiResponse extends PlaygroundApiResponse<PlaygroundMessage[]> {
226
+ /** Whether there are more messages to fetch */
227
+ hasMore?: boolean;
228
+ /** Current session status */
229
+ sessionStatus?: PlaygroundSessionStatus;
230
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Playground Types
3
+ *
4
+ * TypeScript types for the Playground feature, enabling interactive
5
+ * workflow testing with chat interface and session management.
6
+ *
7
+ * @module types/playground
8
+ */
9
+ /**
10
+ * Chat input detection patterns for identifying chat nodes in workflows
11
+ */
12
+ export const CHAT_INPUT_PATTERNS = [
13
+ 'chat_input',
14
+ 'text_input',
15
+ 'user_input',
16
+ 'message_input',
17
+ 'prompt_input'
18
+ ];
19
+ /**
20
+ * Check if a node type is a chat input node
21
+ *
22
+ * @param nodeTypeId - The node type identifier
23
+ * @returns True if the node is a chat input type
24
+ */
25
+ export function isChatInputNode(nodeTypeId) {
26
+ const normalizedId = nodeTypeId.toLowerCase();
27
+ return CHAT_INPUT_PATTERNS.some((pattern) => normalizedId.includes(pattern));
28
+ }
@@ -148,3 +148,45 @@ export declare function isArrayDataType(dataType: string): boolean;
148
148
  * @returns The element type (e.g., "string") or null if not an array
149
149
  */
150
150
  export declare function getArrayElementType(arrayDataType: string): string | null;
151
+ /**
152
+ * Parse a hex color string to RGB components
153
+ * @param hex - Hex color string (e.g., "#f59e0b" or "f59e0b")
154
+ * @returns Object with r, g, b values (0-255) or null if invalid
155
+ */
156
+ export declare function hexToRgb(hex: string): {
157
+ r: number;
158
+ g: number;
159
+ b: number;
160
+ } | null;
161
+ /**
162
+ * Convert RGB components to hex color string
163
+ * @param r - Red component (0-255)
164
+ * @param g - Green component (0-255)
165
+ * @param b - Blue component (0-255)
166
+ * @returns Hex color string with # prefix
167
+ */
168
+ export declare function rgbToHex(r: number, g: number, b: number): string;
169
+ /**
170
+ * Generate a light tint of a color (similar to Tailwind's -50 shade)
171
+ * Creates a very light background-friendly version of the color
172
+ * @param hex - Base hex color string
173
+ * @returns Light tint hex color string
174
+ */
175
+ export declare function getLightTint(hex: string): string;
176
+ /**
177
+ * Generate a border tint of a color (similar to Tailwind's -300 shade)
178
+ * Creates a medium-light version suitable for borders
179
+ * @param hex - Base hex color string
180
+ * @returns Border tint hex color string
181
+ */
182
+ export declare function getBorderTint(hex: string): string;
183
+ /**
184
+ * Generate color variants for theming a component
185
+ * @param baseColor - Base hex color string
186
+ * @returns Object with base, light, and border color variants
187
+ */
188
+ export declare function getColorVariants(baseColor: string): {
189
+ base: string;
190
+ light: string;
191
+ border: string;
192
+ };
@@ -302,3 +302,80 @@ export function getArrayElementType(arrayDataType) {
302
302
  }
303
303
  return null;
304
304
  }
305
+ /**
306
+ * Parse a hex color string to RGB components
307
+ * @param hex - Hex color string (e.g., "#f59e0b" or "f59e0b")
308
+ * @returns Object with r, g, b values (0-255) or null if invalid
309
+ */
310
+ export function hexToRgb(hex) {
311
+ const cleanHex = hex.replace(/^#/, '');
312
+ if (!/^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
313
+ return null;
314
+ }
315
+ const r = parseInt(cleanHex.substring(0, 2), 16);
316
+ const g = parseInt(cleanHex.substring(2, 4), 16);
317
+ const b = parseInt(cleanHex.substring(4, 6), 16);
318
+ return { r, g, b };
319
+ }
320
+ /**
321
+ * Convert RGB components to hex color string
322
+ * @param r - Red component (0-255)
323
+ * @param g - Green component (0-255)
324
+ * @param b - Blue component (0-255)
325
+ * @returns Hex color string with # prefix
326
+ */
327
+ export function rgbToHex(r, g, b) {
328
+ const toHex = (value) => {
329
+ const clamped = Math.max(0, Math.min(255, Math.round(value)));
330
+ return clamped.toString(16).padStart(2, '0');
331
+ };
332
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
333
+ }
334
+ /**
335
+ * Generate a light tint of a color (similar to Tailwind's -50 shade)
336
+ * Creates a very light background-friendly version of the color
337
+ * @param hex - Base hex color string
338
+ * @returns Light tint hex color string
339
+ */
340
+ export function getLightTint(hex) {
341
+ const rgb = hexToRgb(hex);
342
+ if (!rgb) {
343
+ return '#fffbeb'; // Fallback to amber-50
344
+ }
345
+ // Mix with white at 95% to create a very light tint
346
+ const mixRatio = 0.95;
347
+ const r = rgb.r + (255 - rgb.r) * mixRatio;
348
+ const g = rgb.g + (255 - rgb.g) * mixRatio;
349
+ const b = rgb.b + (255 - rgb.b) * mixRatio;
350
+ return rgbToHex(r, g, b);
351
+ }
352
+ /**
353
+ * Generate a border tint of a color (similar to Tailwind's -300 shade)
354
+ * Creates a medium-light version suitable for borders
355
+ * @param hex - Base hex color string
356
+ * @returns Border tint hex color string
357
+ */
358
+ export function getBorderTint(hex) {
359
+ const rgb = hexToRgb(hex);
360
+ if (!rgb) {
361
+ return '#fcd34d'; // Fallback to amber-300
362
+ }
363
+ // Mix with white at 60% to create a medium-light tint
364
+ const mixRatio = 0.6;
365
+ const r = rgb.r + (255 - rgb.r) * mixRatio;
366
+ const g = rgb.g + (255 - rgb.g) * mixRatio;
367
+ const b = rgb.b + (255 - rgb.b) * mixRatio;
368
+ return rgbToHex(r, g, b);
369
+ }
370
+ /**
371
+ * Generate color variants for theming a component
372
+ * @param baseColor - Base hex color string
373
+ * @returns Object with base, light, and border color variants
374
+ */
375
+ export function getColorVariants(baseColor) {
376
+ return {
377
+ base: baseColor,
378
+ light: getLightTint(baseColor),
379
+ border: getBorderTint(baseColor)
380
+ };
381
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@d34dman/flowdrop",
3
3
  "license": "MIT",
4
4
  "private": false,
5
- "version": "0.0.29",
5
+ "version": "0.0.31",
6
6
  "scripts": {
7
7
  "dev": "vite dev",
8
8
  "build": "vite build && npm run prepack",
@@ -118,6 +118,11 @@
118
118
  "svelte": "./dist/display/index.js",
119
119
  "default": "./dist/display/index.js"
120
120
  },
121
+ "./playground": {
122
+ "types": "./dist/playground/index.d.ts",
123
+ "svelte": "./dist/playground/index.js",
124
+ "default": "./dist/playground/index.js"
125
+ },
121
126
  "./styles": "./dist/styles/base.css",
122
127
  "./styles/*": "./dist/styles/*"
123
128
  },