@flowdrop/flowdrop 1.3.0 → 1.5.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 (114) hide show
  1. package/README.md +68 -24
  2. package/dist/adapters/WorkflowAdapter.js +2 -22
  3. package/dist/adapters/agentspec/autoLayout.d.ts +51 -5
  4. package/dist/adapters/agentspec/autoLayout.js +120 -23
  5. package/dist/chat/commandClassifier.d.ts +19 -0
  6. package/dist/chat/commandClassifier.js +30 -0
  7. package/dist/chat/index.d.ts +27 -0
  8. package/dist/chat/index.js +32 -0
  9. package/dist/chat/responseParser.d.ts +21 -0
  10. package/dist/chat/responseParser.js +87 -0
  11. package/dist/commands/batch.d.ts +18 -0
  12. package/dist/commands/batch.js +56 -0
  13. package/dist/commands/executor.d.ts +37 -0
  14. package/dist/commands/executor.js +1044 -0
  15. package/dist/commands/index.d.ts +14 -0
  16. package/dist/commands/index.js +17 -0
  17. package/dist/commands/parser.d.ts +16 -0
  18. package/dist/commands/parser.js +278 -0
  19. package/dist/commands/positioner.d.ts +19 -0
  20. package/dist/commands/positioner.js +33 -0
  21. package/dist/commands/storeIntegration.svelte.d.ts +16 -0
  22. package/dist/commands/storeIntegration.svelte.js +67 -0
  23. package/dist/commands/types.d.ts +343 -0
  24. package/dist/commands/types.js +45 -0
  25. package/dist/components/App.svelte +431 -17
  26. package/dist/components/App.svelte.d.ts +10 -0
  27. package/dist/components/CanvasBanner.stories.svelte +6 -2
  28. package/dist/components/CanvasController.svelte +38 -0
  29. package/dist/components/CanvasController.svelte.d.ts +32 -0
  30. package/dist/components/ConfigMappingRow.svelte +130 -0
  31. package/dist/components/ConfigMappingRow.svelte.d.ts +8 -0
  32. package/dist/components/ConfigPanel.svelte +56 -7
  33. package/dist/components/ConfigPanel.svelte.d.ts +2 -0
  34. package/dist/components/FlowDropEdge.svelte +8 -57
  35. package/dist/components/Logo.svelte +14 -14
  36. package/dist/components/LogsSidebar.svelte +5 -5
  37. package/dist/components/Navbar.svelte +58 -10
  38. package/dist/components/Navbar.svelte.d.ts +7 -0
  39. package/dist/components/NodeSidebar.svelte +238 -362
  40. package/dist/components/NodeSwapPicker.svelte +537 -0
  41. package/dist/components/NodeSwapPicker.svelte.d.ts +16 -0
  42. package/dist/components/PortMappingRow.svelte +209 -0
  43. package/dist/components/PortMappingRow.svelte.d.ts +12 -0
  44. package/dist/components/SwapMappingEditor.svelte +550 -0
  45. package/dist/components/SwapMappingEditor.svelte.d.ts +12 -0
  46. package/dist/components/WorkflowEditor.svelte +99 -4
  47. package/dist/components/WorkflowEditor.svelte.d.ts +8 -0
  48. package/dist/components/chat/AIChatPanel.svelte +658 -0
  49. package/dist/components/chat/AIChatPanel.svelte.d.ts +13 -0
  50. package/dist/components/chat/CommandPreview.svelte +184 -0
  51. package/dist/components/chat/CommandPreview.svelte.d.ts +9 -0
  52. package/dist/components/console/CommandConsole.stories.svelte +93 -0
  53. package/dist/components/console/CommandConsole.stories.svelte.d.ts +27 -0
  54. package/dist/components/console/CommandConsole.svelte +259 -0
  55. package/dist/components/console/CommandConsole.svelte.d.ts +11 -0
  56. package/dist/components/console/ConsoleAutocomplete.svelte +139 -0
  57. package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +21 -0
  58. package/dist/components/console/ConsoleInput.svelte +712 -0
  59. package/dist/components/console/ConsoleInput.svelte.d.ts +16 -0
  60. package/dist/components/console/ConsoleOutput.svelte +121 -0
  61. package/dist/components/console/ConsoleOutput.svelte.d.ts +11 -0
  62. package/dist/components/console/formatters.d.ts +26 -0
  63. package/dist/components/console/formatters.js +118 -0
  64. package/dist/components/interrupt/index.d.ts +1 -0
  65. package/dist/components/interrupt/index.js +1 -0
  66. package/dist/components/nodes/SimpleNode.stories.svelte +64 -0
  67. package/dist/components/nodes/SimpleNode.svelte +27 -11
  68. package/dist/components/nodes/SquareNode.stories.svelte +45 -0
  69. package/dist/components/nodes/SquareNode.svelte +27 -11
  70. package/dist/components/nodes/WorkflowNode.stories.svelte +63 -0
  71. package/dist/config/endpoints.d.ts +8 -0
  72. package/dist/config/endpoints.js +5 -0
  73. package/dist/core/index.d.ts +5 -0
  74. package/dist/core/index.js +9 -0
  75. package/dist/editor/index.d.ts +3 -1
  76. package/dist/editor/index.js +4 -2
  77. package/dist/helpers/proximityConnect.js +8 -1
  78. package/dist/helpers/workflowEditorHelper.d.ts +3 -53
  79. package/dist/helpers/workflowEditorHelper.js +13 -228
  80. package/dist/playground/index.d.ts +1 -1
  81. package/dist/playground/index.js +1 -1
  82. package/dist/schemas/v1/workflow.schema.json +107 -22
  83. package/dist/services/chatService.d.ts +65 -0
  84. package/dist/services/chatService.js +131 -0
  85. package/dist/services/historyService.d.ts +6 -4
  86. package/dist/services/historyService.js +21 -6
  87. package/dist/skins/slate.js +16 -0
  88. package/dist/stores/interruptStore.svelte.js +6 -1
  89. package/dist/stores/playgroundStore.svelte.d.ts +1 -1
  90. package/dist/stores/playgroundStore.svelte.js +11 -2
  91. package/dist/stores/portCoordinateStore.svelte.d.ts +4 -0
  92. package/dist/stores/portCoordinateStore.svelte.js +20 -26
  93. package/dist/stores/workflowStore.svelte.d.ts +31 -2
  94. package/dist/stores/workflowStore.svelte.js +84 -64
  95. package/dist/stories/EdgeDecorator.svelte +4 -4
  96. package/dist/styles/base.css +48 -0
  97. package/dist/svelte-app.d.ts +7 -1
  98. package/dist/svelte-app.js +4 -1
  99. package/dist/types/chat.d.ts +63 -0
  100. package/dist/types/chat.js +9 -0
  101. package/dist/types/events.d.ts +28 -2
  102. package/dist/types/events.js +1 -0
  103. package/dist/types/index.d.ts +8 -0
  104. package/dist/types/settings.d.ts +6 -0
  105. package/dist/types/settings.js +3 -0
  106. package/dist/utils/edgeStyling.d.ts +42 -0
  107. package/dist/utils/edgeStyling.js +176 -0
  108. package/dist/utils/nodeIds.d.ts +31 -0
  109. package/dist/utils/nodeIds.js +42 -0
  110. package/dist/utils/nodeSwap.d.ts +221 -0
  111. package/dist/utils/nodeSwap.js +686 -0
  112. package/package.json +6 -1
  113. package/dist/helpers/nodeLayoutHelper.d.ts +0 -14
  114. package/dist/helpers/nodeLayoutHelper.js +0 -19
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Response Parser for LLM Chat Interface
3
+ *
4
+ * Extracts DSL commands from LLM markdown responses by parsing
5
+ * fenced code blocks (```flowdrop or bare ```).
6
+ *
7
+ * @module chat/responseParser
8
+ */
9
+ /**
10
+ * Extract DSL commands from an LLM response string.
11
+ *
12
+ * Parses fenced code blocks labeled `flowdrop` (preferred) or bare
13
+ * fenced code blocks (fallback). Text outside code blocks becomes
14
+ * the explanation. Empty lines and comment lines inside code blocks
15
+ * are skipped.
16
+ *
17
+ * @param llmResponse - The raw LLM response text (may contain markdown)
18
+ * @returns Extracted commands and explanation text
19
+ */
20
+ export function extractCommands(llmResponse) {
21
+ const commands = [];
22
+ const explanationParts = [];
23
+ const lines = llmResponse.split("\n");
24
+ let inCodeBlock = false;
25
+ let isFlowdropBlock = false;
26
+ let currentExplanation = [];
27
+ let multilineBuffer = null;
28
+ for (const line of lines) {
29
+ const trimmed = line.trim();
30
+ // Check for code block fence opening/closing
31
+ if (trimmed.startsWith("```")) {
32
+ if (!inCodeBlock) {
33
+ // Opening fence
34
+ inCodeBlock = true;
35
+ const lang = trimmed.slice(3).trim().toLowerCase();
36
+ isFlowdropBlock = lang === "flowdrop";
37
+ // Flush accumulated explanation text
38
+ if (currentExplanation.length > 0) {
39
+ explanationParts.push(currentExplanation.join("\n"));
40
+ currentExplanation = [];
41
+ }
42
+ }
43
+ else {
44
+ // Closing fence
45
+ inCodeBlock = false;
46
+ isFlowdropBlock = false;
47
+ }
48
+ continue;
49
+ }
50
+ if (inCodeBlock && isFlowdropBlock) {
51
+ // Skip empty lines and comment lines inside code blocks
52
+ if (trimmed === "" || trimmed.startsWith("#") || trimmed.startsWith("//")) {
53
+ continue;
54
+ }
55
+ // Detect opening triple-quote without a closing one on the same line —
56
+ // start accumulating a multiline value block
57
+ if (multilineBuffer !== null) {
58
+ // We're inside a triple-quoted value; check for closing """
59
+ if (trimmed === '"""' || trimmed.endsWith('"""')) {
60
+ multilineBuffer.push(line);
61
+ commands.push(multilineBuffer.join("\n"));
62
+ multilineBuffer = null;
63
+ }
64
+ else {
65
+ multilineBuffer.push(line); // preserve raw indentation inside value
66
+ }
67
+ continue;
68
+ }
69
+ const tripleOpen = trimmed.indexOf('"""');
70
+ if (tripleOpen !== -1 && trimmed.indexOf('"""', tripleOpen + 3) === -1) {
71
+ // Opening triple-quote with no closing on this line — start buffer
72
+ multilineBuffer = [trimmed];
73
+ continue;
74
+ }
75
+ commands.push(trimmed);
76
+ }
77
+ else if (!inCodeBlock) {
78
+ currentExplanation.push(line);
79
+ }
80
+ }
81
+ // Flush remaining explanation text
82
+ if (currentExplanation.length > 0) {
83
+ explanationParts.push(currentExplanation.join("\n"));
84
+ }
85
+ const explanation = explanationParts.join("\n").trim();
86
+ return { explanation, commands };
87
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Batch Command Executor
3
+ *
4
+ * Executes multiple commands as a single atomic operation wrapped in a
5
+ * transaction. A single undo reverts the entire batch.
6
+ *
7
+ * @module commands/batch
8
+ */
9
+ import type { Command, CommandContext, BatchResult } from "./types.js";
10
+ /**
11
+ * Execute an array of commands as a single atomic transaction.
12
+ *
13
+ * - Calls dispatch.startTransaction() before the first command
14
+ * - Re-reads workflow via context.getWorkflow() before each command
15
+ * - On success of all: calls dispatch.commitTransaction()
16
+ * - On first error: calls dispatch.cancelTransaction() and stops
17
+ */
18
+ export declare function executeBatch(commands: Command[], context: CommandContext): BatchResult;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Batch Command Executor
3
+ *
4
+ * Executes multiple commands as a single atomic operation wrapped in a
5
+ * transaction. A single undo reverts the entire batch.
6
+ *
7
+ * @module commands/batch
8
+ */
9
+ import { executeCommand } from "./executor.js";
10
+ /**
11
+ * Execute an array of commands as a single atomic transaction.
12
+ *
13
+ * - Calls dispatch.startTransaction() before the first command
14
+ * - Re-reads workflow via context.getWorkflow() before each command
15
+ * - On success of all: calls dispatch.commitTransaction()
16
+ * - On first error: calls dispatch.cancelTransaction() and stops
17
+ */
18
+ export function executeBatch(commands, context) {
19
+ const totalCount = commands.length;
20
+ if (totalCount === 0) {
21
+ return {
22
+ ok: true,
23
+ results: [],
24
+ completedCount: 0,
25
+ totalCount: 0,
26
+ };
27
+ }
28
+ const description = totalCount === 1
29
+ ? `batch: 1 command`
30
+ : `batch: ${totalCount} commands`;
31
+ context.dispatch.startTransaction(description);
32
+ const results = [];
33
+ for (let i = 0; i < commands.length; i++) {
34
+ // Re-read workflow before each command to avoid stale state
35
+ // (context.getWorkflow() is live, so this ensures fresh data)
36
+ const result = executeCommand(commands[i], context);
37
+ results.push(result);
38
+ if (!result.ok) {
39
+ context.dispatch.cancelTransaction();
40
+ return {
41
+ ok: false,
42
+ results,
43
+ completedCount: i,
44
+ totalCount,
45
+ error: result.error,
46
+ };
47
+ }
48
+ }
49
+ context.dispatch.commitTransaction();
50
+ return {
51
+ ok: true,
52
+ results,
53
+ completedCount: totalCount,
54
+ totalCount,
55
+ };
56
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Command Executor
3
+ *
4
+ * Executes parsed Command objects against a CommandContext,
5
+ * dispatching mutations to the workflow store.
6
+ *
7
+ * @module commands/executor
8
+ */
9
+ import type { Command, CommandContext, CommandResult } from "./types.js";
10
+ import type { WorkflowNode } from "../types/index.js";
11
+ /**
12
+ * Convert an internal namespaced node ID to a DSL short ID.
13
+ * "agentspec.llm_node.1" → "llm_node.1"
14
+ * "llm_node.1" → "llm_node.1" (no namespace, unchanged)
15
+ */
16
+ export declare function toShortId(internalId: string): string;
17
+ /**
18
+ * Convert a namespaced type ID to a short type ID.
19
+ * "agentspec.llm_node" → "llm_node"
20
+ * "llm_node" → "llm_node" (no namespace, unchanged)
21
+ */
22
+ export declare function toShortTypeId(typeId: string): string;
23
+ /**
24
+ * Resolve a DSL short ID (e.g. "llm_node.1") to the actual workflow node.
25
+ * Tries direct match first, then looks for a namespaced match.
26
+ */
27
+ export declare function resolveNode(shortId: string, nodes: WorkflowNode[]): WorkflowNode | undefined;
28
+ /** All command help entries */
29
+ export declare const COMMAND_HELP: Array<{
30
+ name: string;
31
+ syntax: string;
32
+ description: string;
33
+ }>;
34
+ /**
35
+ * Execute a parsed command against a workflow context.
36
+ */
37
+ export declare function executeCommand(command: Command, context: CommandContext): CommandResult;