@flowdrop/flowdrop 2.0.0-beta.1 → 2.0.0-beta.2
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.
- package/CHANGELOG.md +33 -0
- package/MIGRATION-2.0.md +160 -3
- package/dist/api/enhanced-client.js +6 -11
- package/dist/components/App.svelte +1 -0
- package/dist/components/ConfigForm.svelte +6 -2
- package/dist/components/PipelineStatus.svelte +6 -1
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/SchemaForm.svelte +4 -2
- package/dist/components/WorkflowEditor.svelte +4 -1
- package/dist/components/WorkflowEditor.svelte.d.ts +3 -0
- package/dist/components/chat/AIChatPanel.svelte +6 -1
- package/dist/components/form/FormAutocomplete.svelte +8 -9
- package/dist/components/form/FormFieldLight.svelte +30 -1
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/interrupt/InterruptBubble.svelte +11 -2
- package/dist/components/playground/PipelineKanbanView.svelte +4 -2
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +20 -3
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +4 -2
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +76 -25
- package/dist/components/playground/Playground.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundApp.svelte +5 -0
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundModal.svelte +5 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundStudio.svelte +7 -1
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
- package/dist/config/endpoints.d.ts +23 -0
- package/dist/config/endpoints.js +28 -0
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +2 -6
- package/dist/display/index.d.ts +6 -1
- package/dist/display/index.js +9 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/form/full.d.ts +2 -1
- package/dist/form/full.js +4 -1
- package/dist/form/index.d.ts +0 -1
- package/dist/form/index.js +3 -2
- package/dist/helpers/workflowEditorHelper.d.ts +4 -2
- package/dist/helpers/workflowEditorHelper.js +4 -3
- package/dist/playground/index.d.ts +2 -2
- package/dist/playground/index.js +2 -2
- package/dist/playground/mount.d.ts +10 -0
- package/dist/playground/mount.js +8 -4
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -39
- package/dist/registry/builtinNodes.js +6 -53
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -2
- package/dist/services/apiVariableService.js +12 -26
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +4 -3
- package/dist/services/chatService.js +13 -18
- package/dist/services/interruptService.d.ts +7 -6
- package/dist/services/interruptService.js +19 -21
- package/dist/services/playgroundService.d.ts +9 -8
- package/dist/services/playgroundService.js +23 -25
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/stores/apiContext.d.ts +11 -0
- package/dist/stores/apiContext.js +15 -0
- package/dist/stores/categoriesStore.svelte.js +0 -1
- package/dist/stores/playgroundStore.svelte.js +0 -2
- package/dist/svelte-app.js +2 -1
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +0 -1
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/nodeTypes.js +1 -1
- package/package.json +2 -1
|
@@ -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
|
|
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
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
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
|
|
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
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
|
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
|
|
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
|
*/
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* @module services/playgroundService
|
|
8
8
|
*/
|
|
9
9
|
import { defaultShouldStopPolling } from '../types/playground.js';
|
|
10
|
-
import { buildEndpointUrl
|
|
10
|
+
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
11
|
+
import { authenticatedFetch } from '../utils/fetchWithAuth.js';
|
|
11
12
|
import { logger } from '../utils/logger.js';
|
|
12
13
|
/**
|
|
13
14
|
* Default polling interval in milliseconds
|
|
@@ -64,14 +65,11 @@ export class PlaygroundService {
|
|
|
64
65
|
* @param options - Fetch options
|
|
65
66
|
* @returns The parsed JSON response
|
|
66
67
|
*/
|
|
67
|
-
async request(config, url, options = {}) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
...headers,
|
|
73
|
-
...options.headers
|
|
74
|
-
}
|
|
68
|
+
async request(config, url, options = {}, authProvider) {
|
|
69
|
+
const response = await authenticatedFetch(url, options, {
|
|
70
|
+
config,
|
|
71
|
+
endpointKey: 'playground',
|
|
72
|
+
authProvider
|
|
75
73
|
});
|
|
76
74
|
if (!response.ok) {
|
|
77
75
|
const errorData = await response.json().catch(() => ({}));
|
|
@@ -92,7 +90,7 @@ export class PlaygroundService {
|
|
|
92
90
|
* @param options - Optional pagination parameters
|
|
93
91
|
* @returns Array of playground sessions
|
|
94
92
|
*/
|
|
95
|
-
async listSessions(endpointConfig, workflowId, options) {
|
|
93
|
+
async listSessions(endpointConfig, workflowId, options, authProvider) {
|
|
96
94
|
const config = this.getConfig(endpointConfig);
|
|
97
95
|
let url = buildEndpointUrl(config, config.endpoints.playground.listSessions, {
|
|
98
96
|
id: workflowId
|
|
@@ -109,7 +107,7 @@ export class PlaygroundService {
|
|
|
109
107
|
if (queryString) {
|
|
110
108
|
url = `${url}?${queryString}`;
|
|
111
109
|
}
|
|
112
|
-
const response = await this.request(config, url);
|
|
110
|
+
const response = await this.request(config, url, {}, authProvider);
|
|
113
111
|
return response.data ?? [];
|
|
114
112
|
}
|
|
115
113
|
/**
|
|
@@ -120,7 +118,7 @@ export class PlaygroundService {
|
|
|
120
118
|
* @param metadata - Optional session metadata
|
|
121
119
|
* @returns The created session
|
|
122
120
|
*/
|
|
123
|
-
async createSession(endpointConfig, workflowId, name, metadata) {
|
|
121
|
+
async createSession(endpointConfig, workflowId, name, metadata, authProvider) {
|
|
124
122
|
const config = this.getConfig(endpointConfig);
|
|
125
123
|
const url = buildEndpointUrl(config, config.endpoints.playground.createSession, {
|
|
126
124
|
id: workflowId
|
|
@@ -128,7 +126,7 @@ export class PlaygroundService {
|
|
|
128
126
|
const response = await this.request(config, url, {
|
|
129
127
|
method: 'POST',
|
|
130
128
|
body: JSON.stringify({ name, metadata })
|
|
131
|
-
});
|
|
129
|
+
}, authProvider);
|
|
132
130
|
if (!response.data) {
|
|
133
131
|
throw new Error('Failed to create session: No data returned');
|
|
134
132
|
}
|
|
@@ -140,12 +138,12 @@ export class PlaygroundService {
|
|
|
140
138
|
* @param sessionId - The session UUID
|
|
141
139
|
* @returns The session details
|
|
142
140
|
*/
|
|
143
|
-
async getSession(endpointConfig, sessionId) {
|
|
141
|
+
async getSession(endpointConfig, sessionId, authProvider) {
|
|
144
142
|
const config = this.getConfig(endpointConfig);
|
|
145
143
|
const url = buildEndpointUrl(config, config.endpoints.playground.getSession, {
|
|
146
144
|
sessionId
|
|
147
145
|
});
|
|
148
|
-
const response = await this.request(config, url);
|
|
146
|
+
const response = await this.request(config, url, {}, authProvider);
|
|
149
147
|
if (!response.data) {
|
|
150
148
|
throw new Error('Session not found');
|
|
151
149
|
}
|
|
@@ -156,14 +154,14 @@ export class PlaygroundService {
|
|
|
156
154
|
*
|
|
157
155
|
* @param sessionId - The session UUID
|
|
158
156
|
*/
|
|
159
|
-
async deleteSession(endpointConfig, sessionId) {
|
|
157
|
+
async deleteSession(endpointConfig, sessionId, authProvider) {
|
|
160
158
|
const config = this.getConfig(endpointConfig);
|
|
161
159
|
const url = buildEndpointUrl(config, config.endpoints.playground.deleteSession, {
|
|
162
160
|
sessionId
|
|
163
161
|
});
|
|
164
162
|
await this.request(config, url, {
|
|
165
163
|
method: 'DELETE'
|
|
166
|
-
});
|
|
164
|
+
}, authProvider);
|
|
167
165
|
}
|
|
168
166
|
// =========================================================================
|
|
169
167
|
// Message Handling
|
|
@@ -181,7 +179,7 @@ export class PlaygroundService {
|
|
|
181
179
|
* @param options - Pagination options
|
|
182
180
|
* @returns Messages and session status
|
|
183
181
|
*/
|
|
184
|
-
async getMessages(endpointConfig, sessionId, options = {}) {
|
|
182
|
+
async getMessages(endpointConfig, sessionId, options = {}, authProvider) {
|
|
185
183
|
const config = this.getConfig(endpointConfig);
|
|
186
184
|
let url = buildEndpointUrl(config, config.endpoints.playground.getMessages, {
|
|
187
185
|
sessionId
|
|
@@ -203,7 +201,7 @@ export class PlaygroundService {
|
|
|
203
201
|
if (queryString) {
|
|
204
202
|
url = `${url}?${queryString}`;
|
|
205
203
|
}
|
|
206
|
-
return this.request(config, url);
|
|
204
|
+
return this.request(config, url, {}, authProvider);
|
|
207
205
|
}
|
|
208
206
|
/**
|
|
209
207
|
* Send a message to a playground session
|
|
@@ -213,7 +211,7 @@ export class PlaygroundService {
|
|
|
213
211
|
* @param inputs - Optional additional inputs for workflow nodes
|
|
214
212
|
* @returns The created message
|
|
215
213
|
*/
|
|
216
|
-
async sendMessage(endpointConfig, sessionId, content, inputs) {
|
|
214
|
+
async sendMessage(endpointConfig, sessionId, content, inputs, authProvider) {
|
|
217
215
|
const config = this.getConfig(endpointConfig);
|
|
218
216
|
const url = buildEndpointUrl(config, config.endpoints.playground.sendMessage, {
|
|
219
217
|
sessionId
|
|
@@ -225,7 +223,7 @@ export class PlaygroundService {
|
|
|
225
223
|
const response = await this.request(config, url, {
|
|
226
224
|
method: 'POST',
|
|
227
225
|
body: JSON.stringify(requestBody)
|
|
228
|
-
});
|
|
226
|
+
}, authProvider);
|
|
229
227
|
if (!response.data) {
|
|
230
228
|
throw new Error('Failed to send message: No data returned');
|
|
231
229
|
}
|
|
@@ -236,14 +234,14 @@ export class PlaygroundService {
|
|
|
236
234
|
*
|
|
237
235
|
* @param sessionId - The session UUID
|
|
238
236
|
*/
|
|
239
|
-
async stopExecution(endpointConfig, sessionId) {
|
|
237
|
+
async stopExecution(endpointConfig, sessionId, authProvider) {
|
|
240
238
|
const config = this.getConfig(endpointConfig);
|
|
241
239
|
const url = buildEndpointUrl(config, config.endpoints.playground.stopExecution, {
|
|
242
240
|
sessionId
|
|
243
241
|
});
|
|
244
242
|
await this.request(config, url, {
|
|
245
243
|
method: 'POST'
|
|
246
|
-
});
|
|
244
|
+
}, authProvider);
|
|
247
245
|
}
|
|
248
246
|
// =========================================================================
|
|
249
247
|
// Polling
|
|
@@ -257,7 +255,7 @@ export class PlaygroundService {
|
|
|
257
255
|
* @param shouldStopPolling - Optional override for stop conditions (default: defaultShouldStopPolling)
|
|
258
256
|
* @param initialSequenceNumber - Optional sequence number to seed polling from (avoids re-fetching already loaded messages)
|
|
259
257
|
*/
|
|
260
|
-
startPolling(endpointConfig, sessionId, callback, interval = DEFAULT_POLLING_INTERVAL, shouldStopPolling, initialSequenceNumber) {
|
|
258
|
+
startPolling(endpointConfig, sessionId, callback, interval = DEFAULT_POLLING_INTERVAL, shouldStopPolling, initialSequenceNumber, authProvider) {
|
|
261
259
|
// Stop any existing polling
|
|
262
260
|
this.stopPolling();
|
|
263
261
|
this.pollingSessionId = sessionId;
|
|
@@ -271,7 +269,7 @@ export class PlaygroundService {
|
|
|
271
269
|
try {
|
|
272
270
|
const response = await this.getMessages(endpointConfig, sessionId, {
|
|
273
271
|
since: this.lastSequenceNumber ?? undefined
|
|
274
|
-
});
|
|
272
|
+
}, authProvider);
|
|
275
273
|
// Update last sequence number cursor
|
|
276
274
|
if (response.data && response.data.length > 0) {
|
|
277
275
|
const lastMessage = response.data[response.data.length - 1];
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Port Configuration API Service
|
|
3
3
|
* Handles fetching port configuration from the backend
|
|
4
4
|
*/
|
|
5
|
-
import { buildEndpointUrl
|
|
5
|
+
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
6
|
+
import { authenticatedFetch } from '../utils/fetchWithAuth.js';
|
|
6
7
|
import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.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 fetchPortConfig(endpointConfig, authProvider) {
|
|
12
13
|
try {
|
|
13
14
|
const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.portConfig);
|
|
14
|
-
const
|
|
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: 'portConfig', authProvider });
|
|
19
16
|
if (!response.ok) {
|
|
20
17
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
21
18
|
}
|
|
@@ -9,12 +9,15 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { FlowDropSettings, PartialSettings } from '../types/settings.js';
|
|
11
11
|
import type { EndpointConfig } from '../config/endpoints.js';
|
|
12
|
+
import type { AuthProvider } from '../types/auth.js';
|
|
12
13
|
/**
|
|
13
|
-
* Set the endpoint configuration for settings API
|
|
14
|
+
* Set the endpoint configuration (and optional auth provider) for settings API
|
|
15
|
+
* calls.
|
|
14
16
|
*
|
|
15
17
|
* @param config - Endpoint configuration
|
|
18
|
+
* @param provider - Optional auth provider supplying request auth headers
|
|
16
19
|
*/
|
|
17
|
-
export declare function setSettingsEndpointConfig(config: EndpointConfig): void;
|
|
20
|
+
export declare function setSettingsEndpointConfig(config: EndpointConfig, provider?: AuthProvider): void;
|
|
18
21
|
/**
|
|
19
22
|
* Get the current endpoint configuration
|
|
20
23
|
*
|
|
@@ -62,8 +65,9 @@ export declare class SettingsService {
|
|
|
62
65
|
* Create a new settings service instance
|
|
63
66
|
*
|
|
64
67
|
* @param config - Endpoint configuration
|
|
68
|
+
* @param authProvider - Optional auth provider applied to settings requests
|
|
65
69
|
*/
|
|
66
|
-
constructor(config: EndpointConfig);
|
|
70
|
+
constructor(config: EndpointConfig, authProvider?: AuthProvider);
|
|
67
71
|
/**
|
|
68
72
|
* Get user preferences from the backend
|
|
69
73
|
*
|
|
@@ -87,6 +91,7 @@ export declare class SettingsService {
|
|
|
87
91
|
* Create a settings service instance
|
|
88
92
|
*
|
|
89
93
|
* @param config - Endpoint configuration
|
|
94
|
+
* @param authProvider - Optional auth provider applied to settings requests
|
|
90
95
|
* @returns SettingsService instance
|
|
91
96
|
*/
|
|
92
|
-
export declare function createSettingsService(config: EndpointConfig): SettingsService;
|
|
97
|
+
export declare function createSettingsService(config: EndpointConfig, authProvider?: AuthProvider): SettingsService;
|