@flowdrop/flowdrop 2.0.0-beta.1 → 2.0.0-beta.3

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 (149) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/MIGRATION-2.0.md +173 -3
  3. package/dist/api/enhanced-client.js +6 -11
  4. package/dist/components/App.svelte +22 -45
  5. package/dist/components/App.svelte.d.ts +2 -7
  6. package/dist/components/CanvasIconButton.svelte +76 -0
  7. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  8. package/dist/components/ConfigForm.svelte +6 -21
  9. package/dist/components/ConfigPanel.svelte +4 -3
  10. package/dist/components/LogoWordmark.svelte +113 -0
  11. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  12. package/dist/components/Navbar.svelte +8 -59
  13. package/dist/components/NodeSidebar.svelte +4 -11
  14. package/dist/components/NodeSwapPicker.svelte +0 -2
  15. package/dist/components/PipelineStatus.svelte +6 -1
  16. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  17. package/dist/components/PortMappingRow.svelte +0 -2
  18. package/dist/components/SchemaForm.svelte +4 -14
  19. package/dist/components/SettingsModal.svelte +0 -5
  20. package/dist/components/SettingsPanel.svelte +2 -6
  21. package/dist/components/ThemeToggle.svelte +0 -5
  22. package/dist/components/UniversalNode.svelte +32 -1
  23. package/dist/components/WorkflowEditor.svelte +66 -52
  24. package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
  25. package/dist/components/chat/AIChatPanel.svelte +7 -2
  26. package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
  27. package/dist/components/console/ConsoleOutput.svelte +2 -2
  28. package/dist/components/form/FormArray.svelte +0 -16
  29. package/dist/components/form/FormAutocomplete.svelte +18 -15
  30. package/dist/components/form/FormCheckboxGroup.svelte +0 -4
  31. package/dist/components/form/FormCodeEditor.svelte +9 -7
  32. package/dist/components/form/FormFieldLight.svelte +33 -4
  33. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  34. package/dist/components/form/FormMarkdownEditor.svelte +8 -5
  35. package/dist/components/form/FormNumberField.svelte +0 -4
  36. package/dist/components/form/FormRangeField.svelte +1 -20
  37. package/dist/components/form/FormSelect.svelte +10 -6
  38. package/dist/components/form/FormTemplateEditor.svelte +6 -4
  39. package/dist/components/form/FormTextField.svelte +10 -6
  40. package/dist/components/form/FormTextarea.svelte +10 -6
  41. package/dist/components/form/FormToggle.svelte +0 -4
  42. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  43. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  44. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  45. package/dist/components/icons/MenuIcon.svelte +4 -0
  46. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  47. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  48. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  49. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  50. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  51. package/dist/components/interrupt/InterruptBubble.svelte +11 -12
  52. package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
  53. package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
  54. package/dist/components/layouts/MainLayout.svelte +4 -5
  55. package/dist/components/nodes/AtomNode.svelte +46 -34
  56. package/dist/components/nodes/GatewayNode.svelte +91 -99
  57. package/dist/components/nodes/IdeaNode.svelte +62 -90
  58. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  59. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  60. package/dist/components/nodes/NotesNode.svelte +70 -81
  61. package/dist/components/nodes/SimpleNode.svelte +28 -78
  62. package/dist/components/nodes/SquareNode.svelte +79 -109
  63. package/dist/components/nodes/TerminalNode.svelte +28 -86
  64. package/dist/components/nodes/ToolNode.svelte +82 -95
  65. package/dist/components/nodes/WorkflowNode.svelte +91 -100
  66. package/dist/components/playground/ChatInput.svelte +0 -1
  67. package/dist/components/playground/InputCollector.svelte +0 -2
  68. package/dist/components/playground/PipelineKanbanView.svelte +4 -2
  69. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  70. package/dist/components/playground/PipelinePanel.svelte +20 -3
  71. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  72. package/dist/components/playground/PipelineTableView.svelte +4 -2
  73. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  74. package/dist/components/playground/Playground.svelte +76 -25
  75. package/dist/components/playground/Playground.svelte.d.ts +3 -0
  76. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  77. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  78. package/dist/components/playground/PlaygroundModal.svelte +5 -0
  79. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  80. package/dist/components/playground/PlaygroundStudio.svelte +7 -6
  81. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  82. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
  83. package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
  84. package/dist/config/endpoints.d.ts +23 -0
  85. package/dist/config/endpoints.js +28 -0
  86. package/dist/core/index.d.ts +1 -2
  87. package/dist/core/index.js +2 -6
  88. package/dist/display/index.d.ts +6 -1
  89. package/dist/display/index.js +9 -1
  90. package/dist/editor/index.d.ts +1 -1
  91. package/dist/editor/index.js +1 -1
  92. package/dist/form/full.d.ts +2 -1
  93. package/dist/form/full.js +4 -1
  94. package/dist/form/index.d.ts +0 -1
  95. package/dist/form/index.js +3 -2
  96. package/dist/helpers/workflowEditorHelper.d.ts +4 -2
  97. package/dist/helpers/workflowEditorHelper.js +4 -3
  98. package/dist/playground/index.d.ts +2 -2
  99. package/dist/playground/index.js +2 -2
  100. package/dist/playground/mount.d.ts +19 -5
  101. package/dist/playground/mount.js +16 -8
  102. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  103. package/dist/registry/builtinNodeTypes.js +67 -0
  104. package/dist/registry/builtinNodes.d.ts +2 -39
  105. package/dist/registry/builtinNodes.js +6 -53
  106. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  107. package/dist/services/agentSpecExecutionService.js +0 -2
  108. package/dist/services/apiVariableService.js +12 -26
  109. package/dist/services/categoriesApi.js +3 -6
  110. package/dist/services/chatService.d.ts +4 -3
  111. package/dist/services/chatService.js +13 -18
  112. package/dist/services/interruptService.d.ts +7 -6
  113. package/dist/services/interruptService.js +19 -21
  114. package/dist/services/playgroundService.d.ts +9 -8
  115. package/dist/services/playgroundService.js +23 -25
  116. package/dist/services/portConfigApi.js +3 -6
  117. package/dist/services/settingsService.d.ts +9 -4
  118. package/dist/services/settingsService.js +23 -12
  119. package/dist/skins/drafter.d.ts +30 -0
  120. package/dist/skins/drafter.js +185 -0
  121. package/dist/skins/index.d.ts +2 -1
  122. package/dist/skins/index.js +4 -2
  123. package/dist/stores/apiContext.d.ts +11 -0
  124. package/dist/stores/apiContext.js +15 -0
  125. package/dist/stores/categoriesStore.svelte.js +0 -1
  126. package/dist/stores/playgroundStore.svelte.js +0 -2
  127. package/dist/styles/base.css +38 -9
  128. package/dist/styles/tokens.css +54 -2
  129. package/dist/svelte-app.d.ts +6 -0
  130. package/dist/svelte-app.js +4 -2
  131. package/dist/themes/drafter.d.ts +2 -0
  132. package/dist/themes/drafter.js +15 -0
  133. package/dist/themes/index.d.ts +2 -1
  134. package/dist/themes/index.js +8 -2
  135. package/dist/types/auth.d.ts +9 -51
  136. package/dist/types/auth.js +4 -54
  137. package/dist/types/events.d.ts +18 -0
  138. package/dist/types/events.js +2 -1
  139. package/dist/types/index.d.ts +4 -2
  140. package/dist/types/index.js +0 -1
  141. package/dist/types/settings.d.ts +1 -1
  142. package/dist/types/settings.js +1 -1
  143. package/dist/types/skin.d.ts +1 -1
  144. package/dist/types/theme.d.ts +16 -2
  145. package/dist/utils/edgeStyling.js +9 -5
  146. package/dist/utils/fetchWithAuth.d.ts +36 -15
  147. package/dist/utils/fetchWithAuth.js +53 -23
  148. package/dist/utils/nodeTypes.js +1 -1
  149. package/package.json +2 -1
@@ -6,6 +6,7 @@
6
6
  * ensuring all built-in node types are available without user action.
7
7
  */
8
8
  import {} from './nodeComponentRegistry.js';
9
+ import { FLOWDROP_SOURCE } from './builtinNodeTypes.js';
9
10
  import WorkflowNode from '../components/nodes/WorkflowNode.svelte';
10
11
  import SimpleNode from '../components/nodes/SimpleNode.svelte';
11
12
  import SquareNode from '../components/nodes/SquareNode.svelte';
@@ -15,10 +16,11 @@ import GatewayNode from '../components/nodes/GatewayNode.svelte';
15
16
  import NotesNode from '../components/nodes/NotesNode.svelte';
16
17
  import TerminalNode from '../components/nodes/TerminalNode.svelte';
17
18
  import IdeaNode from '../components/nodes/IdeaNode.svelte';
18
- /**
19
- * Source identifier for built-in FlowDrop components
20
- */
21
- export const FLOWDROP_SOURCE = 'flowdrop';
19
+ // Pure type metadata + resolution helpers are re-exported for backward
20
+ // compatibility they now live in a component-free module so that
21
+ // type-only consumers (e.g. utils/nodeTypes.ts, reachable from `core`) do
22
+ // not statically pull in the node components below.
23
+ export { FLOWDROP_SOURCE, BUILTIN_TYPE_ALIASES, BUILTIN_NODE_TYPES, resolveBuiltinAlias, isBuiltinType, getBuiltinTypes } from './builtinNodeTypes.js';
22
24
  /**
23
25
  * Built-in FlowDrop node component registrations.
24
26
  * These are the default node types that ship with FlowDrop.
@@ -124,52 +126,3 @@ export const BUILTIN_NODE_COMPONENTS = [
124
126
  statusSize: 'sm'
125
127
  }
126
128
  ];
127
- /**
128
- * Alias mapping for type resolution.
129
- * Maps alternative type names to their canonical registration.
130
- */
131
- export const BUILTIN_TYPE_ALIASES = {
132
- default: 'workflowNode'
133
- };
134
- /**
135
- * Get the canonical type for a given type string.
136
- * Handles aliases like "default" -> "workflowNode".
137
- *
138
- * @param type - The type string to resolve
139
- * @returns The canonical type string
140
- */
141
- export function resolveBuiltinAlias(type) {
142
- return BUILTIN_TYPE_ALIASES[type] ?? type;
143
- }
144
- /**
145
- * Check if a type is a built-in FlowDrop type.
146
- *
147
- * @param type - The type to check
148
- * @returns true if this is a built-in type
149
- */
150
- export function isBuiltinType(type) {
151
- const canonicalType = resolveBuiltinAlias(type);
152
- return BUILTIN_NODE_COMPONENTS.some((reg) => reg.type === canonicalType);
153
- }
154
- /**
155
- * Get all built-in type identifiers.
156
- *
157
- * @returns Array of built-in type strings
158
- */
159
- export function getBuiltinTypes() {
160
- return BUILTIN_NODE_COMPONENTS.map((reg) => reg.type);
161
- }
162
- /**
163
- * Array of built-in type strings for runtime validation.
164
- */
165
- export const BUILTIN_NODE_TYPES = [
166
- 'workflowNode',
167
- 'simple',
168
- 'square',
169
- 'atom',
170
- 'tool',
171
- 'gateway',
172
- 'note',
173
- 'terminal',
174
- 'idea'
175
- ];
@@ -102,5 +102,3 @@ export declare class AgentSpecExecutionService {
102
102
  private mapSingleNodeStatus;
103
103
  private mapToFlowDropStatus;
104
104
  }
105
- /** Singleton instance */
106
- export declare const agentSpecExecutionService: AgentSpecExecutionService;
@@ -332,5 +332,3 @@ export class AgentSpecExecutionService {
332
332
  }
333
333
  }
334
334
  }
335
- /** Singleton instance */
336
- export const agentSpecExecutionService = AgentSpecExecutionService.getInstance();
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * @module services/apiVariableService
7
7
  */
8
- import { logger } from '../utils/logger.js';
9
8
  import { DEFAULT_CACHE_TTL_MS } from '../config/constants.js';
9
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
10
10
  /**
11
11
  * Variable schema cache with TTL support
12
12
  * Key format: `variables:{workflowId}:{nodeId}`
@@ -142,25 +142,9 @@ export async function fetchVariableSchema(endpointConfig, workflowId, nodeId, co
142
142
  // Prepare request options
143
143
  const method = endpoint.method ?? 'GET';
144
144
  const timeout = endpoint.timeout ?? 30000;
145
- const headers = {
146
- Accept: 'application/json',
147
- 'Content-Type': 'application/json',
148
- ...endpoint.headers
149
- };
150
- // Add auth headers from AuthProvider if available
151
- if (authProvider) {
152
- try {
153
- const authHeaders = await authProvider.getAuthHeaders();
154
- Object.assign(headers, authHeaders);
155
- }
156
- catch (error) {
157
- logger.warn('Failed to get auth headers:', error);
158
- }
159
- }
160
145
  // Prepare fetch options
161
146
  const fetchOptions = {
162
147
  method,
163
- headers,
164
148
  signal: AbortSignal.timeout(timeout)
165
149
  };
166
150
  // Add body for non-GET requests
@@ -169,7 +153,16 @@ export async function fetchVariableSchema(endpointConfig, workflowId, nodeId, co
169
153
  fetchOptions.body = JSON.stringify(resolvedBody);
170
154
  }
171
155
  try {
172
- const response = await fetch(url, fetchOptions);
156
+ // authenticatedFetch merges auth headers and transparently refreshes +
157
+ // retries once on 401 via the provider's onUnauthorized hook.
158
+ const response = await authenticatedFetch(url, fetchOptions, {
159
+ authProvider,
160
+ baseHeaders: {
161
+ Accept: 'application/json',
162
+ 'Content-Type': 'application/json',
163
+ ...endpoint.headers
164
+ }
165
+ });
173
166
  // Handle 404 as "no variables available"
174
167
  if (response.status === 404) {
175
168
  return {
@@ -179,15 +172,8 @@ export async function fetchVariableSchema(endpointConfig, workflowId, nodeId, co
179
172
  };
180
173
  }
181
174
  if (!response.ok) {
182
- // Handle authentication errors
175
+ // Auth errors remain after the provider's refresh attempt.
183
176
  if (response.status === 401 || response.status === 403) {
184
- if (authProvider?.onUnauthorized) {
185
- const refreshed = await authProvider.onUnauthorized();
186
- if (refreshed) {
187
- // Retry with refreshed auth
188
- return fetchVariableSchema(endpointConfig, workflowId, nodeId, config, authProvider);
189
- }
190
- }
191
177
  return {
192
178
  success: false,
193
179
  error: 'Authentication failed'
@@ -2,7 +2,8 @@
2
2
  * Categories API Service
3
3
  * Handles fetching category definitions from the backend
4
4
  */
5
- import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
5
+ import { buildEndpointUrl } from '../config/endpoints.js';
6
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
6
7
  import { DEFAULT_CATEGORIES } from '../config/defaultCategories.js';
7
8
  import { logger } from '../utils/logger.js';
8
9
  /**
@@ -11,11 +12,7 @@ import { logger } from '../utils/logger.js';
11
12
  export async function fetchCategories(endpointConfig, authProvider) {
12
13
  try {
13
14
  const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.categories);
14
- const configHeaders = getEndpointHeaders(endpointConfig, 'categories');
15
- const authHeaders = authProvider ? await authProvider.getAuthHeaders() : {};
16
- const response = await fetch(url, {
17
- headers: { ...configHeaders, ...authHeaders }
18
- });
15
+ const response = await authenticatedFetch(url, {}, { config: endpointConfig, endpointKey: 'categories', authProvider });
19
16
  if (!response.ok) {
20
17
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
21
18
  }
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { ChatRequest, ChatResponse, ChatHistoryMessage } from '../types/chat.js';
10
10
  import type { EndpointConfig } from '../config/endpoints.js';
11
+ import type { AuthProvider } from '../types/auth.js';
11
12
  /**
12
13
  * Chat Service class
13
14
  *
@@ -48,20 +49,20 @@ export declare class ChatService {
48
49
  * @param request - The chat request payload
49
50
  * @returns The chat response from the LLM
50
51
  */
51
- sendMessage(endpointConfig: EndpointConfig | null, workflowId: string, request: ChatRequest): Promise<ChatResponse>;
52
+ sendMessage(endpointConfig: EndpointConfig | null, workflowId: string, request: ChatRequest, authProvider?: AuthProvider): Promise<ChatResponse>;
52
53
  /**
53
54
  * Get conversation history for a workflow
54
55
  *
55
56
  * @param workflowId - The workflow ID
56
57
  * @returns Array of chat history messages
57
58
  */
58
- getHistory(endpointConfig: EndpointConfig | null, workflowId: string): Promise<ChatHistoryMessage[]>;
59
+ getHistory(endpointConfig: EndpointConfig | null, workflowId: string, authProvider?: AuthProvider): Promise<ChatHistoryMessage[]>;
59
60
  /**
60
61
  * Clear conversation history for a workflow
61
62
  *
62
63
  * @param workflowId - The workflow ID
63
64
  */
64
- clearHistory(endpointConfig: EndpointConfig | null, workflowId: string): Promise<void>;
65
+ clearHistory(endpointConfig: EndpointConfig | null, workflowId: string, authProvider?: AuthProvider): Promise<void>;
65
66
  }
66
67
  /**
67
68
  * Pre-instantiated ChatService singleton
@@ -6,7 +6,8 @@
6
6
  *
7
7
  * @module services/chatService
8
8
  */
9
- import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
9
+ import { buildEndpointUrl } from '../config/endpoints.js';
10
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
10
11
  import { logger } from '../utils/logger.js';
11
12
  /**
12
13
  * Chat Service class
@@ -50,14 +51,11 @@ export class ChatService {
50
51
  * @param options - Fetch options
51
52
  * @returns The parsed JSON response
52
53
  */
53
- async request(config, url, options = {}) {
54
- const headers = getEndpointHeaders(config, 'chat');
55
- const response = await fetch(url, {
56
- ...options,
57
- headers: {
58
- ...headers,
59
- ...options.headers
60
- }
54
+ async request(config, url, options = {}, authProvider) {
55
+ const response = await authenticatedFetch(url, options, {
56
+ config,
57
+ endpointKey: 'chat',
58
+ authProvider
61
59
  });
62
60
  if (!response.ok) {
63
61
  const errorData = await response.json().catch(() => ({}));
@@ -83,7 +81,7 @@ export class ChatService {
83
81
  * @param request - The chat request payload
84
82
  * @returns The chat response from the LLM
85
83
  */
86
- async sendMessage(endpointConfig, workflowId, request) {
84
+ async sendMessage(endpointConfig, workflowId, request, authProvider) {
87
85
  const config = this.getConfig(endpointConfig);
88
86
  const url = buildEndpointUrl(config, config.endpoints.chat.sendMessage, {
89
87
  id: workflowId
@@ -92,7 +90,7 @@ export class ChatService {
92
90
  return this.request(config, url, {
93
91
  method: 'POST',
94
92
  body: JSON.stringify(request)
95
- });
93
+ }, authProvider);
96
94
  }
97
95
  /**
98
96
  * Get conversation history for a workflow
@@ -100,29 +98,26 @@ export class ChatService {
100
98
  * @param workflowId - The workflow ID
101
99
  * @returns Array of chat history messages
102
100
  */
103
- async getHistory(endpointConfig, workflowId) {
101
+ async getHistory(endpointConfig, workflowId, authProvider) {
104
102
  const config = this.getConfig(endpointConfig);
105
103
  const url = buildEndpointUrl(config, config.endpoints.chat.getHistory, {
106
104
  id: workflowId
107
105
  });
108
106
  logger.debug('[ChatService] Getting history from', url);
109
- return this.request(config, url);
107
+ return this.request(config, url, {}, authProvider);
110
108
  }
111
109
  /**
112
110
  * Clear conversation history for a workflow
113
111
  *
114
112
  * @param workflowId - The workflow ID
115
113
  */
116
- async clearHistory(endpointConfig, workflowId) {
114
+ async clearHistory(endpointConfig, workflowId, authProvider) {
117
115
  const config = this.getConfig(endpointConfig);
118
116
  const url = buildEndpointUrl(config, config.endpoints.chat.clearHistory, {
119
117
  id: workflowId
120
118
  });
121
119
  logger.debug('[ChatService] Clearing history at', url);
122
- await fetch(url, {
123
- method: 'DELETE',
124
- headers: getEndpointHeaders(config, 'chat')
125
- });
120
+ await authenticatedFetch(url, { method: 'DELETE' }, { config, endpointKey: 'chat', authProvider });
126
121
  }
127
122
  }
128
123
  /**
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import type { Interrupt, InterruptPollingConfig } from '../types/interrupt.js';
11
11
  import type { EndpointConfig } from '../config/endpoints.js';
12
+ import type { AuthProvider } from '../types/auth.js';
12
13
  /**
13
14
  * Interrupt Service class
14
15
  *
@@ -75,7 +76,7 @@ export declare class InterruptService {
75
76
  * @param interruptId - The interrupt UUID
76
77
  * @returns The interrupt details
77
78
  */
78
- getInterrupt(endpointConfig: EndpointConfig | null, interruptId: string): Promise<Interrupt>;
79
+ getInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, authProvider?: AuthProvider): Promise<Interrupt>;
79
80
  /**
80
81
  * Resolve an interrupt with user response
81
82
  *
@@ -83,28 +84,28 @@ export declare class InterruptService {
83
84
  * @param value - The user's response value
84
85
  * @returns The updated interrupt
85
86
  */
86
- resolveInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, value: unknown): Promise<Interrupt>;
87
+ resolveInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, value: unknown, authProvider?: AuthProvider): Promise<Interrupt>;
87
88
  /**
88
89
  * Cancel a pending interrupt
89
90
  *
90
91
  * @param interruptId - The interrupt UUID
91
92
  * @returns The updated interrupt
92
93
  */
93
- cancelInterrupt(endpointConfig: EndpointConfig | null, interruptId: string): Promise<Interrupt>;
94
+ cancelInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, authProvider?: AuthProvider): Promise<Interrupt>;
94
95
  /**
95
96
  * List interrupts for a playground session
96
97
  *
97
98
  * @param sessionId - The session UUID
98
99
  * @returns Array of interrupts for the session
99
100
  */
100
- listSessionInterrupts(endpointConfig: EndpointConfig | null, sessionId: string): Promise<Interrupt[]>;
101
+ listSessionInterrupts(endpointConfig: EndpointConfig | null, sessionId: string, authProvider?: AuthProvider): Promise<Interrupt[]>;
101
102
  /**
102
103
  * List interrupts for a pipeline
103
104
  *
104
105
  * @param pipelineId - The pipeline UUID
105
106
  * @returns Array of interrupts for the pipeline
106
107
  */
107
- listPipelineInterrupts(endpointConfig: EndpointConfig | null, pipelineId: string): Promise<Interrupt[]>;
108
+ listPipelineInterrupts(endpointConfig: EndpointConfig | null, pipelineId: string, authProvider?: AuthProvider): Promise<Interrupt[]>;
108
109
  /**
109
110
  * Start polling for interrupts in a session
110
111
  *
@@ -114,7 +115,7 @@ export declare class InterruptService {
114
115
  * @param sessionId - The session UUID to poll
115
116
  * @param callback - Callback function to handle new interrupts
116
117
  */
117
- startPolling(endpointConfig: EndpointConfig | null, sessionId: string, callback: (interrupts: Interrupt[]) => void): void;
118
+ startPolling(endpointConfig: EndpointConfig | null, sessionId: string, callback: (interrupts: Interrupt[]) => void, authProvider?: AuthProvider): void;
118
119
  /**
119
120
  * Stop polling for interrupts
120
121
  */
@@ -8,7 +8,8 @@
8
8
  * @module services/interruptService
9
9
  */
10
10
  import { defaultInterruptPollingConfig } from '../types/interrupt.js';
11
- import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
11
+ import { buildEndpointUrl } from '../config/endpoints.js';
12
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
12
13
  import { logger } from '../utils/logger.js';
13
14
  /**
14
15
  * Interrupt Service class
@@ -92,14 +93,11 @@ export class InterruptService {
92
93
  * @param options - Fetch options
93
94
  * @returns The parsed JSON response
94
95
  */
95
- async request(config, url, options = {}) {
96
- const headers = getEndpointHeaders(config, 'interrupts');
97
- const response = await fetch(url, {
98
- ...options,
99
- headers: {
100
- ...headers,
101
- ...options.headers
102
- }
96
+ async request(config, url, options = {}, authProvider) {
97
+ const response = await authenticatedFetch(url, options, {
98
+ config,
99
+ endpointKey: 'interrupts',
100
+ authProvider
103
101
  });
104
102
  if (!response.ok) {
105
103
  const errorData = await response.json().catch(() => ({}));
@@ -119,12 +117,12 @@ export class InterruptService {
119
117
  * @param interruptId - The interrupt UUID
120
118
  * @returns The interrupt details
121
119
  */
122
- async getInterrupt(endpointConfig, interruptId) {
120
+ async getInterrupt(endpointConfig, interruptId, authProvider) {
123
121
  const config = this.getConfig(endpointConfig);
124
122
  const url = buildEndpointUrl(config, config.endpoints.interrupts.get, {
125
123
  interruptId
126
124
  });
127
- const response = await this.request(config, url);
125
+ const response = await this.request(config, url, {}, authProvider);
128
126
  if (!response.data) {
129
127
  throw new Error('Interrupt not found');
130
128
  }
@@ -137,7 +135,7 @@ export class InterruptService {
137
135
  * @param value - The user's response value
138
136
  * @returns The updated interrupt
139
137
  */
140
- async resolveInterrupt(endpointConfig, interruptId, value) {
138
+ async resolveInterrupt(endpointConfig, interruptId, value, authProvider) {
141
139
  const config = this.getConfig(endpointConfig);
142
140
  const url = buildEndpointUrl(config, config.endpoints.interrupts.resolve, {
143
141
  interruptId
@@ -146,7 +144,7 @@ export class InterruptService {
146
144
  const response = await this.request(config, url, {
147
145
  method: 'POST',
148
146
  body: JSON.stringify(resolution)
149
- });
147
+ }, authProvider);
150
148
  if (!response.data) {
151
149
  throw new Error('Failed to resolve interrupt: No data returned');
152
150
  }
@@ -158,14 +156,14 @@ export class InterruptService {
158
156
  * @param interruptId - The interrupt UUID
159
157
  * @returns The updated interrupt
160
158
  */
161
- async cancelInterrupt(endpointConfig, interruptId) {
159
+ async cancelInterrupt(endpointConfig, interruptId, authProvider) {
162
160
  const config = this.getConfig(endpointConfig);
163
161
  const url = buildEndpointUrl(config, config.endpoints.interrupts.cancel, {
164
162
  interruptId
165
163
  });
166
164
  const response = await this.request(config, url, {
167
165
  method: 'POST'
168
- });
166
+ }, authProvider);
169
167
  if (!response.data) {
170
168
  throw new Error('Failed to cancel interrupt: No data returned');
171
169
  }
@@ -177,12 +175,12 @@ export class InterruptService {
177
175
  * @param sessionId - The session UUID
178
176
  * @returns Array of interrupts for the session
179
177
  */
180
- async listSessionInterrupts(endpointConfig, sessionId) {
178
+ async listSessionInterrupts(endpointConfig, sessionId, authProvider) {
181
179
  const config = this.getConfig(endpointConfig);
182
180
  const url = buildEndpointUrl(config, config.endpoints.interrupts.listBySession, {
183
181
  sessionId
184
182
  });
185
- const response = await this.request(config, url);
183
+ const response = await this.request(config, url, {}, authProvider);
186
184
  return response.data ?? [];
187
185
  }
188
186
  /**
@@ -191,12 +189,12 @@ export class InterruptService {
191
189
  * @param pipelineId - The pipeline UUID
192
190
  * @returns Array of interrupts for the pipeline
193
191
  */
194
- async listPipelineInterrupts(endpointConfig, pipelineId) {
192
+ async listPipelineInterrupts(endpointConfig, pipelineId, authProvider) {
195
193
  const config = this.getConfig(endpointConfig);
196
194
  const url = buildEndpointUrl(config, config.endpoints.interrupts.listByPipeline, {
197
195
  pipelineId
198
196
  });
199
- const response = await this.request(config, url);
197
+ const response = await this.request(config, url, {}, authProvider);
200
198
  return response.data ?? [];
201
199
  }
202
200
  // =========================================================================
@@ -211,7 +209,7 @@ export class InterruptService {
211
209
  * @param sessionId - The session UUID to poll
212
210
  * @param callback - Callback function to handle new interrupts
213
211
  */
214
- startPolling(endpointConfig, sessionId, callback) {
212
+ startPolling(endpointConfig, sessionId, callback, authProvider) {
215
213
  if (!this.pollingConfig.enabled) {
216
214
  logger.warn('[InterruptService] Polling is disabled. Enable via setPollingConfig().');
217
215
  return;
@@ -225,7 +223,7 @@ export class InterruptService {
225
223
  return;
226
224
  }
227
225
  try {
228
- const interrupts = await this.listSessionInterrupts(endpointConfig, sessionId);
226
+ const interrupts = await this.listSessionInterrupts(endpointConfig, sessionId, authProvider);
229
227
  const pendingInterrupts = interrupts.filter((i) => i.status === 'pending');
230
228
  // Reset backoff on successful request
231
229
  this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { PlaygroundSession, PlaygroundMessage, PlaygroundMessagesApiResponse, PlaygroundSessionStatus } from '../types/playground.js';
10
10
  import type { EndpointConfig } from '../config/endpoints.js';
11
+ import type { AuthProvider } from '../types/auth.js';
11
12
  /**
12
13
  * Pagination options for {@link PlaygroundService.getMessages}.
13
14
  * `since`, `before`, and `latest` are mutually exclusive.
@@ -70,7 +71,7 @@ export declare class PlaygroundService {
70
71
  listSessions(endpointConfig: EndpointConfig | null, workflowId: string, options?: {
71
72
  limit?: number;
72
73
  offset?: number;
73
- }): Promise<PlaygroundSession[]>;
74
+ }, authProvider?: AuthProvider): Promise<PlaygroundSession[]>;
74
75
  /**
75
76
  * Create a new playground session
76
77
  *
@@ -79,20 +80,20 @@ export declare class PlaygroundService {
79
80
  * @param metadata - Optional session metadata
80
81
  * @returns The created session
81
82
  */
82
- createSession(endpointConfig: EndpointConfig | null, workflowId: string, name?: string, metadata?: Record<string, unknown>): Promise<PlaygroundSession>;
83
+ createSession(endpointConfig: EndpointConfig | null, workflowId: string, name?: string, metadata?: Record<string, unknown>, authProvider?: AuthProvider): Promise<PlaygroundSession>;
83
84
  /**
84
85
  * Get a playground session by ID
85
86
  *
86
87
  * @param sessionId - The session UUID
87
88
  * @returns The session details
88
89
  */
89
- getSession(endpointConfig: EndpointConfig | null, sessionId: string): Promise<PlaygroundSession>;
90
+ getSession(endpointConfig: EndpointConfig | null, sessionId: string, authProvider?: AuthProvider): Promise<PlaygroundSession>;
90
91
  /**
91
92
  * Delete a playground session
92
93
  *
93
94
  * @param sessionId - The session UUID
94
95
  */
95
- deleteSession(endpointConfig: EndpointConfig | null, sessionId: string): Promise<void>;
96
+ deleteSession(endpointConfig: EndpointConfig | null, sessionId: string, authProvider?: AuthProvider): Promise<void>;
96
97
  /**
97
98
  * Get messages from a playground session.
98
99
  *
@@ -106,7 +107,7 @@ export declare class PlaygroundService {
106
107
  * @param options - Pagination options
107
108
  * @returns Messages and session status
108
109
  */
109
- getMessages(endpointConfig: EndpointConfig | null, sessionId: string, options?: GetMessagesOptions): Promise<PlaygroundMessagesApiResponse>;
110
+ getMessages(endpointConfig: EndpointConfig | null, sessionId: string, options?: GetMessagesOptions, authProvider?: AuthProvider): Promise<PlaygroundMessagesApiResponse>;
110
111
  /**
111
112
  * Send a message to a playground session
112
113
  *
@@ -115,13 +116,13 @@ export declare class PlaygroundService {
115
116
  * @param inputs - Optional additional inputs for workflow nodes
116
117
  * @returns The created message
117
118
  */
118
- sendMessage(endpointConfig: EndpointConfig | null, sessionId: string, content: string, inputs?: Record<string, unknown>): Promise<PlaygroundMessage>;
119
+ sendMessage(endpointConfig: EndpointConfig | null, sessionId: string, content: string, inputs?: Record<string, unknown>, authProvider?: AuthProvider): Promise<PlaygroundMessage>;
119
120
  /**
120
121
  * Stop execution in a playground session
121
122
  *
122
123
  * @param sessionId - The session UUID
123
124
  */
124
- stopExecution(endpointConfig: EndpointConfig | null, sessionId: string): Promise<void>;
125
+ stopExecution(endpointConfig: EndpointConfig | null, sessionId: string, authProvider?: AuthProvider): Promise<void>;
125
126
  /**
126
127
  * Start polling for new messages
127
128
  *
@@ -131,7 +132,7 @@ export declare class PlaygroundService {
131
132
  * @param shouldStopPolling - Optional override for stop conditions (default: defaultShouldStopPolling)
132
133
  * @param initialSequenceNumber - Optional sequence number to seed polling from (avoids re-fetching already loaded messages)
133
134
  */
134
- startPolling(endpointConfig: EndpointConfig | null, sessionId: string, callback: (response: PlaygroundMessagesApiResponse) => void, interval?: number, shouldStopPolling?: (status: PlaygroundSessionStatus) => boolean, initialSequenceNumber?: number | null): void;
135
+ startPolling(endpointConfig: EndpointConfig | null, sessionId: string, callback: (response: PlaygroundMessagesApiResponse) => void, interval?: number, shouldStopPolling?: (status: PlaygroundSessionStatus) => boolean, initialSequenceNumber?: number | null, authProvider?: AuthProvider): void;
135
136
  /**
136
137
  * Stop polling for messages
137
138
  */