@flowdrop/flowdrop 2.8.0 → 2.10.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 (99) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/dist/commands/executor.js +52 -8
  3. package/dist/commands/types.d.ts +3 -0
  4. package/dist/components/App.svelte +8 -0
  5. package/dist/components/App.svelte.d.ts +6 -0
  6. package/dist/components/CanvasContextMenu.stories.svelte +63 -0
  7. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +19 -0
  8. package/dist/components/CanvasContextMenu.svelte +259 -0
  9. package/dist/components/CanvasContextMenu.svelte.d.ts +16 -0
  10. package/dist/components/CanvasController.svelte +23 -1
  11. package/dist/components/CanvasController.svelte.d.ts +16 -0
  12. package/dist/components/UniversalNode.svelte +12 -13
  13. package/dist/components/WorkflowEditor.svelte +364 -27
  14. package/dist/components/WorkflowEditor.svelte.d.ts +7 -0
  15. package/dist/components/WorkflowInterfaceEditor.svelte +28 -3
  16. package/dist/components/WorkflowInterfaceEntryCard.svelte +112 -2
  17. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +3 -1
  18. package/dist/components/form/FieldFactory.svelte +478 -0
  19. package/dist/components/form/FieldFactory.svelte.d.ts +14 -0
  20. package/dist/components/form/FormField.svelte +19 -404
  21. package/dist/components/form/FormField.svelte.d.ts +2 -27
  22. package/dist/components/form/FormFieldLight.svelte +11 -424
  23. package/dist/components/form/FormFieldLight.svelte.d.ts +2 -28
  24. package/dist/components/form/FormMarkdownEditor.svelte +11 -4
  25. package/dist/components/form/FormTemplateEditor.svelte +12 -5
  26. package/dist/components/form/resolveFieldType.d.ts +18 -15
  27. package/dist/components/form/resolveFieldType.js +33 -12
  28. package/dist/components/form/types.d.ts +14 -2
  29. package/dist/components/nodes/CaptionNode.stories.svelte +65 -0
  30. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +18 -0
  31. package/dist/components/nodes/CaptionNode.svelte +313 -0
  32. package/dist/components/nodes/CaptionNode.svelte.d.ts +16 -0
  33. package/dist/components/nodes/NotesNode.svelte +6 -0
  34. package/dist/components/playground/ChatBubble.svelte +2 -0
  35. package/dist/components/playground/ChatInput.svelte +18 -34
  36. package/dist/components/playground/ChatInput.svelte.d.ts +7 -0
  37. package/dist/components/playground/ControlPanel.svelte +27 -0
  38. package/dist/components/playground/ControlPanel.svelte.d.ts +12 -0
  39. package/dist/components/playground/ExecutionLogs.svelte +11 -8
  40. package/dist/components/playground/InterfaceInputForm.svelte +74 -0
  41. package/dist/components/playground/InterfaceInputForm.svelte.d.ts +14 -0
  42. package/dist/components/playground/LogRow.svelte +2 -0
  43. package/dist/components/playground/MessageCard.svelte +15 -3
  44. package/dist/components/playground/MessageNotice.svelte +2 -0
  45. package/dist/components/playground/MessageStream.svelte +87 -23
  46. package/dist/components/playground/OriginBadge.svelte +48 -0
  47. package/dist/components/playground/OriginBadge.svelte.d.ts +7 -0
  48. package/dist/components/playground/Playground.svelte +155 -38
  49. package/dist/components/playground/messageDisplay.d.ts +23 -1
  50. package/dist/components/playground/messageDisplay.js +49 -0
  51. package/dist/config/endpoints.d.ts +65 -0
  52. package/dist/config/endpoints.js +39 -0
  53. package/dist/core/index.d.ts +6 -3
  54. package/dist/core/index.js +2 -1
  55. package/dist/editor/contextMenu.d.ts +107 -0
  56. package/dist/editor/contextMenu.js +134 -0
  57. package/dist/editor/index.d.ts +2 -0
  58. package/dist/editor/index.js +1 -0
  59. package/dist/index.d.ts +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/messages/defaults.d.ts +63 -0
  62. package/dist/messages/defaults.js +59 -0
  63. package/dist/openapi/v1/openapi.yaml +356 -7
  64. package/dist/playground/commands/registry.js +4 -2
  65. package/dist/playground/index.d.ts +3 -2
  66. package/dist/playground/index.js +2 -1
  67. package/dist/registry/builtinNodeTypes.d.ts +1 -1
  68. package/dist/registry/builtinNodeTypes.js +1 -0
  69. package/dist/registry/builtinNodes.js +13 -0
  70. package/dist/registry/nodeComponentRegistry.d.ts +18 -0
  71. package/dist/registry/nodeComponentRegistry.js +14 -2
  72. package/dist/schemas/v1/workflow.schema.json +22 -1
  73. package/dist/services/historyService.d.ts +1 -1
  74. package/dist/services/historyService.js +2 -2
  75. package/dist/services/playgroundService.d.ts +35 -1
  76. package/dist/services/playgroundService.js +82 -36
  77. package/dist/stores/inlineEditStore.svelte.d.ts +35 -0
  78. package/dist/stores/inlineEditStore.svelte.js +63 -0
  79. package/dist/stores/instanceContainer.svelte.d.ts +6 -0
  80. package/dist/stores/instanceContainer.svelte.js +2 -0
  81. package/dist/stores/playgroundStore.svelte.d.ts +59 -2
  82. package/dist/stores/playgroundStore.svelte.js +128 -2
  83. package/dist/styles/base.css +8 -0
  84. package/dist/styles/tokens.css +8 -0
  85. package/dist/svelte-app.d.ts +15 -0
  86. package/dist/svelte-app.js +6 -4
  87. package/dist/types/index.d.ts +34 -1
  88. package/dist/types/index.js +11 -0
  89. package/dist/types/playground.d.ts +90 -9
  90. package/dist/types/playground.js +12 -4
  91. package/dist/utils/captionText.d.ts +43 -0
  92. package/dist/utils/captionText.js +49 -0
  93. package/dist/utils/focus.d.ts +16 -0
  94. package/dist/utils/focus.js +40 -0
  95. package/dist/utils/nodeTypes.js +1 -0
  96. package/dist/utils/nodeWrapper.js +2 -0
  97. package/dist/utils/workflowInterface.d.ts +83 -1
  98. package/dist/utils/workflowInterface.js +192 -1
  99. package/package.json +1 -1
@@ -31,7 +31,7 @@
31
31
  import type { FlowDropInstance } from '../../stores/instanceContainer.svelte.js';
32
32
  import type { PlaygroundMessagesApiResponse } from '../../types/playground.js';
33
33
  import { logger } from '../../utils/logger.js';
34
- import { m } from '../../messages/index.js';
34
+ import { getMessages } from '../../messages/index.js';
35
35
  import {
36
36
  parseSlashCommand,
37
37
  dispatchCommand,
@@ -39,6 +39,7 @@
39
39
  type CommandOutcome
40
40
  } from '../../playground/commands/index.js';
41
41
  import { resolveRunAction } from '../../playground/runAction.js';
42
+ import type { PlaygroundMessageRequest } from '../../types/playground.js';
42
43
 
43
44
  interface Props {
44
45
  workflowId: string;
@@ -75,6 +76,11 @@
75
76
  // svelte-ignore state_referenced_locally
76
77
  const fd = provideInstance(instance);
77
78
 
79
+ // The messages getter is read from context here, at init: `m()` calls
80
+ // getContext, which throws outside component initialisation, and every
81
+ // read below happens in an event handler or after an await.
82
+ const messages = getMessages();
83
+
78
84
  let loadedInitialSessionId = $state<string | undefined>(undefined);
79
85
  let autoRunTriggered = $state(false);
80
86
  let isRefreshing = $state(false);
@@ -98,6 +104,24 @@
98
104
 
99
105
  const messagePageSize = $derived(config.messagePageSize ?? 50);
100
106
 
107
+ /**
108
+ * How a turn is collected, from the workflow interface's turn ports.
109
+ * `legacy` (no interface, or no `turn` declared) keeps the host-configured
110
+ * behaviour exactly; the other modes follow the interface:
111
+ * - `chat`: the chat box (unless the host hides it with showChatInput:
112
+ * false), plus a form for any other interface inputs;
113
+ * - `form`: a form and Run; the turn sends `inputs` and no content;
114
+ * - `run`: Run alone; the turn sends neither.
115
+ * In `form` and `run` the chat box and predefinedMessage are ignored: the
116
+ * server refuses content for a workflow with no `message` port.
117
+ */
118
+ const inputMode = $derived(fd.playground.inputMode);
119
+ const showChatBox = $derived(
120
+ inputMode === 'legacy'
121
+ ? (config.showChatInput ?? true)
122
+ : inputMode === 'chat' && config.showChatInput !== false
123
+ );
124
+
101
125
  // Vertical resizer state for the ExecutionConsole ↔ ControlPanel split.
102
126
  let playgroundContentEl = $state<HTMLElement | null>(null);
103
127
  let controlPanelHeight = $state(140);
@@ -120,6 +144,17 @@
120
144
  }
121
145
  });
122
146
 
147
+ // A form arriving with the workflow interface needs room beside the
148
+ // composer: grow the panel once (the user can still drag it back).
149
+ let formRoomGiven = false;
150
+ $effect(() => {
151
+ if (fd.playground.interfaceFormEntries.length === 0 || formRoomGiven) return;
152
+ formRoomGiven = true;
153
+ untrack(() => {
154
+ controlPanelHeight = clampControlPanelHeight(Math.max(controlPanelHeight, 320));
155
+ });
156
+ });
157
+
123
158
  const maxControlPanelHeight = $derived(containerHeight ? Math.round(containerHeight * 0.6) : 600);
124
159
 
125
160
  function clampControlPanelHeight(h: number): number {
@@ -201,9 +236,29 @@
201
236
  void loadInitialSession(initialSessionId);
202
237
  });
203
238
 
239
+ /**
240
+ * Make sure the playground knows the workflow's interface.
241
+ *
242
+ * The mode (chat box, form, Run) is read from the interface's turn ports.
243
+ * A workflow passed in with an `interface` key is used as is; when it is
244
+ * missing or has no `interface` key, the workflow is loaded through the
245
+ * workflows API (`workflows.get`). Any failure leaves the playground in
246
+ * `legacy` mode, which is the behaviour it had before turn ports.
247
+ */
248
+ async function ensureWorkflowInterface(): Promise<void> {
249
+ if (workflow?.interface !== undefined || !fd.api.config) return;
250
+ try {
251
+ const loaded = await fd.api.client.loadWorkflow(workflowId);
252
+ if (loaded.interface === undefined) return;
253
+ fd.playground.setWorkflow(workflow ? { ...workflow, interface: loaded.interface } : loaded);
254
+ } catch (err) {
255
+ logger.debug('[Playground] Workflow interface unavailable, keeping legacy input:', err);
256
+ }
257
+ }
258
+
204
259
  async function initializePlayground(): Promise<void> {
205
260
  try {
206
- await loadSessions();
261
+ await Promise.all([loadSessions(), ensureWorkflowInterface()]);
207
262
 
208
263
  if (initialSessionId) {
209
264
  await loadInitialSession(initialSessionId);
@@ -486,10 +541,17 @@
486
541
  * "Run workflow" appearing in the conversation as though a user typed it.
487
542
  */
488
543
  async function startRun(): Promise<void> {
544
+ // A workflow that declares turn ports but no message port runs as a turn
545
+ // on its inputs: no fabricated message, which its server would refuse.
546
+ if (inputMode === 'form' || inputMode === 'run') {
547
+ await takeTurn({});
548
+ return;
549
+ }
550
+
489
551
  const action = resolveRunAction({
490
552
  canLaunch: workflowLaunchService.isSupported(fd.api.config),
491
553
  predefinedMessage: config.predefinedMessage,
492
- defaultMessage: m().playground.chat.predefinedRun
554
+ defaultMessage: messages().playground.chat.predefinedRun
493
555
  });
494
556
 
495
557
  if (action.kind === 'message') {
@@ -503,7 +565,10 @@
503
565
  // Only failures need reporting: a successful launch is evident from the run
504
566
  // itself appearing in the console.
505
567
  if (result.status !== 'launched') {
506
- commandFeedback = describeLaunchResult(result, m().playground.commands);
568
+ commandFeedback = describeLaunchResult(result, messages().playground.commands);
569
+ // A refused launch never sends the `enableRun` message that would
570
+ // otherwise bring Run back.
571
+ fd.playground.releaseRunLock();
507
572
  }
508
573
  }
509
574
 
@@ -554,7 +619,7 @@
554
619
  */
555
620
  async function runCommand(input: string): Promise<void> {
556
621
  const parsed = parseSlashCommand(input);
557
- const msgs = m().playground.commands;
622
+ const msgs = messages().playground.commands;
558
623
 
559
624
  if (parsed.kind === 'unknown') {
560
625
  commandFeedback = {
@@ -591,55 +656,101 @@
591
656
  });
592
657
  }
593
658
 
594
- async function handleSendMessage(content: string): Promise<void> {
659
+ async function handleSendMessage(content: string): Promise<boolean> {
595
660
  // Commands are intercepted *before* the executing guard: /stop is only
596
661
  // useful while a run is in flight, which is exactly when plain text is
597
662
  // refused.
598
663
  const parsed = parseSlashCommand(content);
599
664
  if (parsed.kind === 'command' || parsed.kind === 'unknown') {
600
665
  await runCommand(content);
601
- return;
666
+ return true;
602
667
  }
603
668
 
604
669
  commandFeedback = null;
605
670
 
606
- if (fd.playground.isExecuting) return;
607
-
608
671
  // An escaped message (`//foo`) is sent as its literal text (`/foo`).
609
672
  const messageContent = parsed.kind === 'message' ? parsed.content : content;
610
673
 
611
- if (!fd.playground.currentSession) {
612
- await handleCreateSession();
613
- if (!fd.playground.currentSession) return;
674
+ return takeTurn({ content: messageContent });
675
+ }
676
+
677
+ /**
678
+ * Take one turn: post the request to the session's turn door and tail the
679
+ * session. The interface form's values ride along as `inputs` (none in
680
+ * legacy mode). A refusal (a 400 naming the fix, a 409, …) is shown with the
681
+ * server's own message and leaves the session idle.
682
+ *
683
+ * @returns Whether the turn was accepted
684
+ */
685
+ async function takeTurn(request: PlaygroundMessageRequest): Promise<boolean> {
686
+ // Not `canRun`: a Run click has already taken the run lock by now.
687
+ if (fd.playground.isExecuting || fd.playground.turnPending) {
688
+ fd.playground.releaseRunLock();
689
+ return false;
614
690
  }
691
+ fd.playground.setTurnPending(true);
615
692
 
616
- const sessionId = fd.playground.currentSession!.id;
693
+ try {
694
+ // In legacy mode there are no interface form entries, so `inputs` is
695
+ // `{}` — exactly what the legacy door was always sent.
696
+ const turnInputs = fd.playground.turnInputs;
697
+ if (!turnInputs.ok) {
698
+ fd.playground.setError(
699
+ messages().playground.inputForm.missingRequired({
700
+ names: turnInputs.missing.map((entry) => entry.name ?? entry.id).join(', ')
701
+ })
702
+ );
703
+ fd.playground.releaseRunLock();
704
+ return false;
705
+ }
706
+ const body: PlaygroundMessageRequest = { ...request, inputs: turnInputs.inputs };
617
707
 
618
- fd.playground.updateSessionStatus('running');
619
- fd.playground.pinExecution(null);
620
- fd.playground.setError(null);
708
+ if (!fd.playground.currentSession) {
709
+ await handleCreateSession();
710
+ }
711
+ const sessionId = fd.playground.currentSession?.id;
712
+ if (!sessionId) {
713
+ fd.playground.releaseRunLock();
714
+ return false;
715
+ }
621
716
 
622
- try {
623
- const message = await playgroundService.sendMessage(
624
- fd.api.config,
625
- sessionId,
626
- messageContent,
627
- {},
628
- fd.api.authProvider
629
- );
630
- fd.playground.addMessage(message);
631
- // Only start polling if not already active — avoids resetting the cursor
632
- // mid-session and re-fetching messages that are already in the store.
633
- // Seed from the newest loaded message so polling tails live updates
634
- // rather than crawling forward from the start of the conversation.
635
- if (!playgroundService.isPolling()) {
636
- startPolling(sessionId, true);
717
+ fd.playground.updateSessionStatus('running');
718
+ fd.playground.pinExecution(null);
719
+ fd.playground.setError(null);
720
+
721
+ try {
722
+ const response = await playgroundService.sendTurn(
723
+ fd.api.config,
724
+ sessionId,
725
+ body,
726
+ fd.api.authProvider
727
+ );
728
+ // The legacy door answers with the user's row; the turn door with a
729
+ // turn result, and the row arrives with the poll started below.
730
+ if (response.kind === 'turn') {
731
+ fd.playground.setLastTurn(response.result);
732
+ } else {
733
+ fd.playground.addMessage(response.message);
734
+ fd.playground.setLastTurn(null);
735
+ }
736
+ // Only start polling if not already active — avoids resetting the cursor
737
+ // mid-session and re-fetching messages that are already in the store.
738
+ // Seed from the newest loaded message so polling tails live updates
739
+ // rather than crawling forward from the start of the conversation.
740
+ if (!playgroundService.isPolling()) {
741
+ startPolling(sessionId, true);
742
+ }
743
+ return true;
744
+ } catch (err) {
745
+ const errorMessage = err instanceof Error ? err.message : 'Failed to send message';
746
+ fd.playground.setError(errorMessage);
747
+ fd.playground.updateSessionStatus('idle');
748
+ fd.playground.releaseRunLock();
749
+ logger.error('Failed to send message:', err);
750
+ return false;
637
751
  }
638
- } catch (err) {
639
- const errorMessage = err instanceof Error ? err.message : 'Failed to send message';
640
- fd.playground.setError(errorMessage);
641
- fd.playground.updateSessionStatus('idle');
642
- logger.error('Failed to send message:', err);
752
+ } finally {
753
+ fd.playground.setTurnPending(false);
643
754
  }
644
755
  }
645
756
 
@@ -802,13 +913,19 @@
802
913
  onSendMessage={handleSendMessage}
803
914
  onStopExecution={handleStopExecution}
804
915
  onRunWorkflow={startRun}
916
+ awaitEnableRun={inputMode === 'legacy'}
805
917
  onRefresh={refreshFromServer}
806
918
  enableCommands
807
919
  {commandFeedback}
808
920
  onDismissCommandFeedback={() => (commandFeedback = null)}
809
- showChatInput={config.showChatInput ?? true}
921
+ showChatInput={showChatBox}
810
922
  showRunButton={config.showRunButton ?? true}
811
- predefinedMessage={config.predefinedMessage}
923
+ predefinedMessage={inputMode === 'form' || inputMode === 'run'
924
+ ? undefined
925
+ : config.predefinedMessage}
926
+ formEntries={fd.playground.interfaceFormEntries}
927
+ formValues={fd.playground.formValues}
928
+ onFormChange={(values) => fd.playground.setFormValues(values)}
812
929
  showSessionHeader={config.showSessionHeader ?? true}
813
930
  showNewSessionButton={config.showNewSessionButton ?? true}
814
931
  showSessionList={config.showSessionList ?? true}
@@ -3,9 +3,10 @@
3
3
  * components. Pure functions only — i18n strings come in via the `roles`
4
4
  * argument; the helper has no runtime dependency on the messages context.
5
5
  */
6
- import type { PlaygroundMessage, PlaygroundMessageLevel, PlaygroundMessageRole } from '../../types/playground.js';
6
+ import type { PlaygroundMessage, PlaygroundMessageLevel, PlaygroundMessageOrigin, PlaygroundMessageRole } from '../../types/playground.js';
7
7
  import type { Messages } from '../../messages/types.js';
8
8
  export type RoleLabels = Messages['playground']['roles'];
9
+ export type OriginLabels = Messages['playground']['origins'];
9
10
  export declare function formatTimestamp(timestamp: string): string;
10
11
  export declare function formatDuration(ms: number): string;
11
12
  export declare function getLogLevelIcon(level: PlaygroundMessageLevel | undefined): string;
@@ -17,3 +18,24 @@ export declare function getRoleIcon(role: PlaygroundMessageRole): string;
17
18
  * Anything else returns the role's i18n default.
18
19
  */
19
20
  export declare function getRoleLabel(message: Pick<PlaygroundMessage, 'role' | 'metadata'>, roles: RoleLabels): string;
21
+ /**
22
+ * The origin to badge a message with, or null for none. Absent (older
23
+ * servers), unknown, `user` and `workflow` origins get no badge.
24
+ */
25
+ export declare function getOriginBadge(message: Pick<PlaygroundMessage, 'origin'>): PlaygroundMessageOrigin | null;
26
+ /** A run of adjacent rows collapsed into one group, or a single row. */
27
+ export type MessageRow<T> = {
28
+ kind: 'single';
29
+ item: T;
30
+ } | {
31
+ kind: 'group';
32
+ key: string;
33
+ items: T[];
34
+ };
35
+ /**
36
+ * Fold runs of at least `minRun` adjacent groupable items into one group;
37
+ * everything else stays a single row. Order is preserved. The group key is
38
+ * the first item's key, so a run that grows at its tail keeps its identity
39
+ * (and its open/closed state) across renders.
40
+ */
41
+ export declare function groupAdjacent<T>(items: readonly T[], isGroupable: (item: T) => boolean, keyOf: (item: T) => string, minRun?: number): MessageRow<T>[];
@@ -60,3 +60,52 @@ export function getRoleLabel(message, roles) {
60
60
  return roles.message;
61
61
  }
62
62
  }
63
+ /**
64
+ * Origins that earn a badge. `user` and `workflow` are the conversation
65
+ * itself and stay unbadged; everything else was posted by a component
66
+ * around the conversation and is marked so a reader can tell it apart.
67
+ */
68
+ const BADGED_ORIGINS = new Set([
69
+ 'engine',
70
+ 'playground',
71
+ 'interrupt'
72
+ ]);
73
+ /**
74
+ * The origin to badge a message with, or null for none. Absent (older
75
+ * servers), unknown, `user` and `workflow` origins get no badge.
76
+ */
77
+ export function getOriginBadge(message) {
78
+ const origin = message.origin;
79
+ return origin !== undefined && BADGED_ORIGINS.has(origin) ? origin : null;
80
+ }
81
+ /**
82
+ * Fold runs of at least `minRun` adjacent groupable items into one group;
83
+ * everything else stays a single row. Order is preserved. The group key is
84
+ * the first item's key, so a run that grows at its tail keeps its identity
85
+ * (and its open/closed state) across renders.
86
+ */
87
+ export function groupAdjacent(items, isGroupable, keyOf, minRun = 3) {
88
+ const rows = [];
89
+ let run = [];
90
+ const flush = () => {
91
+ if (run.length >= minRun) {
92
+ rows.push({ kind: 'group', key: keyOf(run[0]), items: run });
93
+ }
94
+ else {
95
+ for (const item of run)
96
+ rows.push({ kind: 'single', item });
97
+ }
98
+ run = [];
99
+ };
100
+ for (const item of items) {
101
+ if (isGroupable(item)) {
102
+ run.push(item);
103
+ }
104
+ else {
105
+ flush();
106
+ rows.push({ kind: 'single', item });
107
+ }
108
+ }
109
+ flush();
110
+ return rows;
111
+ }
@@ -56,6 +56,11 @@ export interface EndpointConfig {
56
56
  execute: string;
57
57
  stop: string;
58
58
  };
59
+ /**
60
+ * Playground endpoints. `listSessions` and `createSession` are always read
61
+ * from here; the per-session keys only while no `sessions` group is
62
+ * configured (servers that predate it serve the session API here).
63
+ */
59
64
  playground: {
60
65
  /** List sessions for a workflow */
61
66
  listSessions: string;
@@ -80,6 +85,44 @@ export interface EndpointConfig {
80
85
  */
81
86
  resetSession?: string;
82
87
  };
88
+ /**
89
+ * One session's own HTTP surface: read, delete, page its messages, take a
90
+ * turn, stop and reset. Keyed by the session's id, independent of which
91
+ * client created it (the Playground, a node session, an integration).
92
+ *
93
+ * Optional as a whole. When present, every per-session call goes here and
94
+ * the matching `playground` keys are no longer read; when absent, those
95
+ * calls stay on the `playground` group, which is what servers that predate
96
+ * this surface serve. Listing and creating sessions for a workflow stay on
97
+ * `playground` either way: they are the console's concern, not the
98
+ * session's. {@link sessionsEndpoints} holds the reference backend's paths.
99
+ *
100
+ * Not part of {@link defaultEndpointConfig} on purpose: hosts merge their
101
+ * endpoint groups over the defaults, so a default here would move every
102
+ * host to paths its server may not serve yet. The host that knows its
103
+ * server sets the group.
104
+ */
105
+ sessions?: {
106
+ /** Get session details (`GET`) */
107
+ get: string;
108
+ /** Delete a session (`DELETE`) */
109
+ delete: string;
110
+ /**
111
+ * Page a session's messages (`GET`; `since`, `before`, `latest` and
112
+ * `limit` query parameters, the same response as `playground.getMessages`).
113
+ */
114
+ messages: string;
115
+ /**
116
+ * Take a turn (`POST`, body `{content?, inputs?}`). Answers with the
117
+ * turn result (`userMessageId`, `pipelineId`, `status`, …), not the
118
+ * user's message row; the row arrives with the next messages poll.
119
+ */
120
+ turn: string;
121
+ /** Stop the running turn (`POST`) */
122
+ stop: string;
123
+ /** Reset a stuck session to idle (`POST`). Optional, as `playground.resetSession`. */
124
+ reset?: string;
125
+ };
83
126
  /**
84
127
  * Operator signals into a *running* pipeline — pause, resume, cancel.
85
128
  *
@@ -198,6 +241,28 @@ export interface EndpointConfig {
198
241
  * Default endpoint configuration
199
242
  */
200
243
  export declare const defaultEndpointConfig: EndpointConfig;
244
+ /**
245
+ * The reference backend's `sessions` group: the session HTTP surface under
246
+ * `/sessions/{sessionId}`. Hosts whose server serves it opt in with
247
+ * `endpoints: { ...defaultEndpointConfig.endpoints, sessions: sessionsEndpoints }`.
248
+ */
249
+ export declare const sessionsEndpoints: NonNullable<EndpointConfig['endpoints']['sessions']>;
250
+ /** One per-session call, named as the `sessions` group names it. */
251
+ export type SessionEndpointKey = keyof NonNullable<EndpointConfig['endpoints']['sessions']>;
252
+ /** A resolved per-session endpoint: its path and the group it came from. */
253
+ export interface ResolvedSessionEndpoint {
254
+ path: string;
255
+ group: 'sessions' | 'playground';
256
+ }
257
+ /**
258
+ * Resolve a per-session call to its path.
259
+ *
260
+ * The `sessions` group wins as a whole when configured; otherwise the call
261
+ * stays on its `playground` key. A key absent from the winning group is a
262
+ * capability the backend does not offer (only `reset` may be absent), so this
263
+ * returns `undefined` rather than borrowing the other group's path.
264
+ */
265
+ export declare function resolveSessionEndpoint(config: EndpointConfig, key: SessionEndpointKey): ResolvedSessionEndpoint | undefined;
201
266
  /**
202
267
  * Create endpoint configuration with custom base URL
203
268
  */
@@ -102,6 +102,45 @@ export const defaultEndpointConfig = {
102
102
  backoff: 'exponential'
103
103
  }
104
104
  };
105
+ /**
106
+ * The reference backend's `sessions` group: the session HTTP surface under
107
+ * `/sessions/{sessionId}`. Hosts whose server serves it opt in with
108
+ * `endpoints: { ...defaultEndpointConfig.endpoints, sessions: sessionsEndpoints }`.
109
+ */
110
+ export const sessionsEndpoints = {
111
+ get: '/sessions/{sessionId}',
112
+ delete: '/sessions/{sessionId}',
113
+ messages: '/sessions/{sessionId}/messages',
114
+ turn: '/sessions/{sessionId}/turn',
115
+ stop: '/sessions/{sessionId}/stop',
116
+ reset: '/sessions/{sessionId}/reset'
117
+ };
118
+ /** Which `playground` key served each per-session call before the `sessions` group. */
119
+ const LEGACY_SESSION_ENDPOINT_KEYS = {
120
+ get: 'getSession',
121
+ delete: 'deleteSession',
122
+ messages: 'getMessages',
123
+ turn: 'sendMessage',
124
+ stop: 'stopExecution',
125
+ reset: 'resetSession'
126
+ };
127
+ /**
128
+ * Resolve a per-session call to its path.
129
+ *
130
+ * The `sessions` group wins as a whole when configured; otherwise the call
131
+ * stays on its `playground` key. A key absent from the winning group is a
132
+ * capability the backend does not offer (only `reset` may be absent), so this
133
+ * returns `undefined` rather than borrowing the other group's path.
134
+ */
135
+ export function resolveSessionEndpoint(config, key) {
136
+ const sessions = config.endpoints.sessions;
137
+ if (sessions) {
138
+ const path = sessions[key];
139
+ return path ? { path, group: 'sessions' } : undefined;
140
+ }
141
+ const path = config.endpoints.playground?.[LEGACY_SESSION_ENDPOINT_KEYS[key]];
142
+ return path ? { path, group: 'playground' } : undefined;
143
+ }
105
144
  /**
106
145
  * Create endpoint configuration with custom base URL
107
146
  */
@@ -16,8 +16,9 @@
16
16
  */
17
17
  export type { WorkflowFormat, BuiltinWorkflowFormat } from '../types/index.js';
18
18
  export { DEFAULT_WORKFLOW_FORMAT } from '../types/index.js';
19
- export type { NodeCategory, BuiltinNodeCategory, CategoryDefinition, NodeDataType, NodePort, DynamicPort, Branch, NodeMetadata, NodeExtensions, NodeUIExtensions, PortsConfig, PortConfigEntry, PortBinding, WorkflowInterface, WorkflowInterfaceEntry, ConfigValues, WorkflowNode, WorkflowEdge, Workflow, ApiResponse, NodesResponse, WorkflowResponse, WorkflowsResponse, ExecutionStatus, ExecutionResult, FlowDropConfig, WorkflowEvents, BuiltinNodeType, PortConfig, PortCompatibilityRule, ConfigSchema, ConfigProperty, HttpMethod, DynamicSchemaEndpoint, ExternalEditLink, ConfigEditOptions, EdgeCategory, UISchemaElementType, UISchemaElementBase, UISchemaControl, UISchemaVerticalLayout, UISchemaGroup, UISchemaElement } from '../types/index.js';
19
+ export type { NodeCategory, BuiltinNodeCategory, CategoryDefinition, NodeDataType, NodePort, DynamicPort, Branch, NodeMetadata, NodeExtensions, NodeUIExtensions, PortsConfig, PortConfigEntry, PortBinding, WorkflowInterface, WorkflowInterfaceEntry, WorkflowInterfaceTurn, ConfigValues, WorkflowNode, WorkflowEdge, Workflow, ApiResponse, NodesResponse, WorkflowResponse, WorkflowsResponse, ExecutionStatus, ExecutionResult, FlowDropConfig, WorkflowEvents, BuiltinNodeType, PortConfig, PortCompatibilityRule, ConfigSchema, ConfigProperty, HttpMethod, DynamicSchemaEndpoint, ExternalEditLink, ConfigEditOptions, EdgeCategory, UISchemaElementType, UISchemaElementBase, UISchemaControl, UISchemaVerticalLayout, UISchemaGroup, UISchemaElement } from '../types/index.js';
20
20
  export { isUISchemaControl, isUISchemaVerticalLayout, isUISchemaGroup } from '../types/index.js';
21
+ export { WORKFLOW_INTERFACE_INPUT_TURNS, WORKFLOW_INTERFACE_OUTPUT_TURNS, DEFAULT_HISTORY_TURN_LIMIT } from '../types/index.js';
21
22
  export type { WorkflowEditorConfig, EditorFeatures, UIConfig, APIConfig, ExecutionConfig, StorageConfig } from '../types/config.js';
22
23
  export type { AuthProvider, StaticAuthConfig, CallbackAuthConfig } from '../types/auth.js';
23
24
  export type { WorkflowChangeType, FlowDropEventHandlers, FlowDropFeatures } from '../types/events.js';
@@ -30,8 +31,9 @@ export type { WorkflowFormatAdapter, FormatValidationResult } from '../registry/
30
31
  export { getBuiltinFormatAdapters } from '../registry/builtinFormats.js';
31
32
  export type { ToastType, ToastOptions } from '../services/toastService.js';
32
33
  export type { DynamicSchemaResult } from '../services/dynamicSchemaService.js';
33
- export type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundMessageRequest, PlaygroundMessagesResult, PlaygroundConfig, PlaygroundMode, PlaygroundSessionStatus, PlaygroundMessageRole, PlaygroundMessageLevel, PlaygroundMessageMetadata, PlaygroundApiResponse, PlaygroundSessionsResponse, PlaygroundSessionResponse, PlaygroundMessageResponse, PlaygroundMessagesApiResponse } from '../types/playground.js';
34
+ export type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundMessageRequest, PlaygroundTurnResult, PlaygroundTurnResponse, PlaygroundMessagesResult, PlaygroundConfig, PlaygroundMode, PlaygroundSessionStatus, PlaygroundMessageRole, PlaygroundMessageLevel, PlaygroundMessageMetadata, PlaygroundMessageDisplay, ResolvedMessageDisplay, PlaygroundMessageOrigin, PlaygroundApiResponse, PlaygroundSessionsResponse, PlaygroundSessionResponse, PlaygroundMessageResponse, PlaygroundMessagesApiResponse } from '../types/playground.js';
34
35
  export { isChatInputNode, CHAT_INPUT_PATTERNS } from '../types/playground.js';
36
+ export type { PlaygroundInputMode } from '../utils/workflowInterface.js';
35
37
  export type { EndpointConfig } from '../config/endpoints.js';
36
38
  export type { FlowDropMountOptions, MountedFlowDropApp, NavbarAction } from '../svelte-app.js';
37
39
  export { StaticAuthProvider, CallbackAuthProvider, NoAuthProvider } from '../types/auth.js';
@@ -48,7 +50,8 @@ export { isLoopbackEdge, isValidLoopbackCycle, hasCycles, hasInvalidCycles } fro
48
50
  export { isFieldOptionArray, normalizeOptions } from '../components/form/types.js';
49
51
  export { resolveScopeToKey, keyToScope, generateDefaultUISchema, collectReferencedKeys } from '../utils/uischema.js';
50
52
  export { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
51
- export { defaultEndpointConfig, createEndpointConfig } from '../config/endpoints.js';
53
+ export { defaultEndpointConfig, createEndpointConfig, sessionsEndpoints, resolveSessionEndpoint } from '../config/endpoints.js';
54
+ export type { SessionEndpointKey, ResolvedSessionEndpoint } from '../config/endpoints.js';
52
55
  export { generateNodeId, extractConfigDefaults } from '../utils/nodeIds.js';
53
56
  export type { AddNodeCommand, DeleteNodeCommand, RenameNodeCommand, SetConfigCommand, GetConfigCommand, ConnectCommand, DisconnectPortsCommand, DisconnectNodeCommand, ListNodesCommand, ListEdgesCommand, ListTypesCommand, DescribeTypeCommand, SearchTypesCommand, InfoCommand, UndoCommand, RedoCommand, ConfigOpenCommand, SelectNodeCommand, HelpCommand, ClearCommand, SwapNodeCommand, MoveNodeCommand, AutoLayoutCommand, Command, ParseResult, CommandErrorCode, AddNodeResultData, ListNodesResultData, ListEdgesResultData, ListTypesResultData, SearchTypesResultData, DescribeTypeResultData, TypeSummary, ConfigKeyDescription, PortDescription, InfoResultData, GetConfigResultData, GetConfigKeyResultData, GetConfigAllResultData, SetConfigResultData, HelpResultData, CommandResultData, CommandResultOk, CommandResultError, CommandResult, BatchResult, UIAction, CommandDispatch, CommandContext } from '../commands/index.js';
54
57
  export { buildTypeMap, parseCommand, executeCommand, toShortId, toShortTypeId, resolveNode, executeBatch, computeAutoPosition } from '../commands/index.js';
@@ -16,6 +16,7 @@
16
16
  */
17
17
  export { DEFAULT_WORKFLOW_FORMAT } from '../types/index.js';
18
18
  export { isUISchemaControl, isUISchemaVerticalLayout, isUISchemaGroup } from '../types/index.js';
19
+ export { WORKFLOW_INTERFACE_INPUT_TURNS, WORKFLOW_INTERFACE_OUTPUT_TURNS, DEFAULT_HISTORY_TURN_LIMIT } from '../types/index.js';
19
20
  // Base registry
20
21
  export { BaseRegistry } from '../registry/BaseRegistry.svelte.js';
21
22
  // Workflow format registry (the class — instances live on `fd.formats`)
@@ -56,7 +57,7 @@ export { resolveScopeToKey, keyToScope, generateDefaultUISchema, collectReferenc
56
57
  // Configuration
57
58
  // ============================================================================
58
59
  export { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
59
- export { defaultEndpointConfig, createEndpointConfig } from '../config/endpoints.js';
60
+ export { defaultEndpointConfig, createEndpointConfig, sessionsEndpoints, resolveSessionEndpoint } from '../config/endpoints.js';
60
61
  // ============================================================================
61
62
  // Shared Utilities
62
63
  // ============================================================================