@d34dman/flowdrop 0.0.37 → 0.0.39
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/LICENSE +21 -0
- package/dist/components/NodeSidebar.svelte +1 -0
- package/dist/components/form/FormCodeEditor.svelte +6 -1
- package/dist/components/interrupt/ChoicePrompt.svelte +389 -0
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +21 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte +280 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/FormPrompt.svelte +223 -0
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +21 -0
- package/dist/components/interrupt/InterruptBubble.svelte +621 -0
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
- package/dist/components/interrupt/TextInputPrompt.svelte +333 -0
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +21 -0
- package/dist/components/interrupt/index.d.ts +13 -0
- package/dist/components/interrupt/index.js +15 -0
- package/dist/components/nodes/GatewayNode.svelte +1 -3
- package/dist/components/nodes/IdeaNode.svelte +30 -35
- package/dist/components/nodes/IdeaNode.svelte.d.ts +1 -1
- package/dist/components/nodes/SimpleNode.svelte +1 -3
- package/dist/components/nodes/TerminalNode.svelte +1 -3
- package/dist/components/nodes/ToolNode.svelte +2 -2
- package/dist/components/nodes/WorkflowNode.svelte +1 -3
- package/dist/components/playground/ChatPanel.svelte +144 -7
- package/dist/components/playground/ChatPanel.svelte.d.ts +2 -0
- package/dist/components/playground/MessageBubble.svelte +1 -3
- package/dist/components/playground/Playground.svelte +50 -5
- package/dist/components/playground/PlaygroundModal.svelte +8 -7
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -3
- package/dist/config/endpoints.d.ts +12 -0
- package/dist/config/endpoints.js +7 -0
- package/dist/playground/index.d.ts +5 -0
- package/dist/playground/index.js +21 -0
- package/dist/playground/mount.d.ts +3 -3
- package/dist/playground/mount.js +30 -22
- package/dist/services/interruptService.d.ts +133 -0
- package/dist/services/interruptService.js +279 -0
- package/dist/stores/interruptStore.d.ts +200 -0
- package/dist/stores/interruptStore.js +424 -0
- package/dist/stores/playgroundStore.d.ts +11 -1
- package/dist/stores/playgroundStore.js +34 -0
- package/dist/styles/base.css +89 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/interrupt.d.ts +305 -0
- package/dist/types/interrupt.js +126 -0
- package/dist/types/interruptState.d.ts +211 -0
- package/dist/types/interruptState.js +308 -0
- package/dist/utils/colors.js +1 -0
- package/dist/utils/connections.js +2 -2
- package/dist/utils/icons.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interrupt Service
|
|
3
|
+
*
|
|
4
|
+
* Handles API interactions for Human-in-the-Loop (HITL) interrupts,
|
|
5
|
+
* including fetching interrupt details, resolving interrupts with user
|
|
6
|
+
* responses, and optional dedicated polling for interrupt status.
|
|
7
|
+
*
|
|
8
|
+
* @module services/interruptService
|
|
9
|
+
*/
|
|
10
|
+
import type { Interrupt, InterruptPollingConfig } from '../types/interrupt.js';
|
|
11
|
+
/**
|
|
12
|
+
* Interrupt Service class
|
|
13
|
+
*
|
|
14
|
+
* Provides methods to interact with interrupt API endpoints including
|
|
15
|
+
* fetching, resolving, cancelling, and listing interrupts.
|
|
16
|
+
* Supports optional dedicated polling for interrupt status.
|
|
17
|
+
*/
|
|
18
|
+
export declare class InterruptService {
|
|
19
|
+
private static instance;
|
|
20
|
+
private pollingInterval;
|
|
21
|
+
private pollingSessionId;
|
|
22
|
+
private currentBackoff;
|
|
23
|
+
private pollingConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Private constructor for singleton pattern
|
|
26
|
+
*/
|
|
27
|
+
private constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Get the singleton instance of InterruptService
|
|
30
|
+
*
|
|
31
|
+
* @returns The InterruptService singleton instance
|
|
32
|
+
*/
|
|
33
|
+
static getInstance(): InterruptService;
|
|
34
|
+
/**
|
|
35
|
+
* Configure interrupt polling settings
|
|
36
|
+
*
|
|
37
|
+
* @param config - Polling configuration options
|
|
38
|
+
*/
|
|
39
|
+
setPollingConfig(config: Partial<InterruptPollingConfig>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get the current polling configuration
|
|
42
|
+
*
|
|
43
|
+
* @returns Current polling configuration
|
|
44
|
+
*/
|
|
45
|
+
getPollingConfig(): InterruptPollingConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Check if interrupt endpoints are configured
|
|
48
|
+
*
|
|
49
|
+
* @returns True if interrupt endpoints are available
|
|
50
|
+
*/
|
|
51
|
+
isConfigured(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get the endpoint configuration
|
|
54
|
+
*
|
|
55
|
+
* @throws Error if endpoint configuration is not set
|
|
56
|
+
* @returns The endpoint configuration
|
|
57
|
+
*/
|
|
58
|
+
private getConfig;
|
|
59
|
+
/**
|
|
60
|
+
* Generic API request helper
|
|
61
|
+
*
|
|
62
|
+
* @param url - The URL to fetch
|
|
63
|
+
* @param options - Fetch options
|
|
64
|
+
* @returns The parsed JSON response
|
|
65
|
+
*/
|
|
66
|
+
private request;
|
|
67
|
+
/**
|
|
68
|
+
* Get interrupt details by ID
|
|
69
|
+
*
|
|
70
|
+
* @param interruptId - The interrupt UUID
|
|
71
|
+
* @returns The interrupt details
|
|
72
|
+
*/
|
|
73
|
+
getInterrupt(interruptId: string): Promise<Interrupt>;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve an interrupt with user response
|
|
76
|
+
*
|
|
77
|
+
* @param interruptId - The interrupt UUID
|
|
78
|
+
* @param value - The user's response value
|
|
79
|
+
* @returns The updated interrupt
|
|
80
|
+
*/
|
|
81
|
+
resolveInterrupt(interruptId: string, value: unknown): Promise<Interrupt>;
|
|
82
|
+
/**
|
|
83
|
+
* Cancel a pending interrupt
|
|
84
|
+
*
|
|
85
|
+
* @param interruptId - The interrupt UUID
|
|
86
|
+
* @returns The updated interrupt
|
|
87
|
+
*/
|
|
88
|
+
cancelInterrupt(interruptId: string): Promise<Interrupt>;
|
|
89
|
+
/**
|
|
90
|
+
* List interrupts for a playground session
|
|
91
|
+
*
|
|
92
|
+
* @param sessionId - The session UUID
|
|
93
|
+
* @returns Array of interrupts for the session
|
|
94
|
+
*/
|
|
95
|
+
listSessionInterrupts(sessionId: string): Promise<Interrupt[]>;
|
|
96
|
+
/**
|
|
97
|
+
* List interrupts for a pipeline
|
|
98
|
+
*
|
|
99
|
+
* @param pipelineId - The pipeline UUID
|
|
100
|
+
* @returns Array of interrupts for the pipeline
|
|
101
|
+
*/
|
|
102
|
+
listPipelineInterrupts(pipelineId: string): Promise<Interrupt[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Start polling for interrupts in a session
|
|
105
|
+
*
|
|
106
|
+
* This is optional - interrupts are typically detected via message metadata.
|
|
107
|
+
* Use this for scenarios where dedicated polling is preferred.
|
|
108
|
+
*
|
|
109
|
+
* @param sessionId - The session UUID to poll
|
|
110
|
+
* @param callback - Callback function to handle new interrupts
|
|
111
|
+
*/
|
|
112
|
+
startPolling(sessionId: string, callback: (interrupts: Interrupt[]) => void): void;
|
|
113
|
+
/**
|
|
114
|
+
* Stop polling for interrupts
|
|
115
|
+
*/
|
|
116
|
+
stopPolling(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Check if polling is active
|
|
119
|
+
*
|
|
120
|
+
* @returns True if polling is active
|
|
121
|
+
*/
|
|
122
|
+
isPolling(): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Get the current polling session ID
|
|
125
|
+
*
|
|
126
|
+
* @returns The session ID being polled, or null
|
|
127
|
+
*/
|
|
128
|
+
getPollingSessionId(): string | null;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Export singleton instance
|
|
132
|
+
*/
|
|
133
|
+
export declare const interruptService: InterruptService;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interrupt Service
|
|
3
|
+
*
|
|
4
|
+
* Handles API interactions for Human-in-the-Loop (HITL) interrupts,
|
|
5
|
+
* including fetching interrupt details, resolving interrupts with user
|
|
6
|
+
* responses, and optional dedicated polling for interrupt status.
|
|
7
|
+
*
|
|
8
|
+
* @module services/interruptService
|
|
9
|
+
*/
|
|
10
|
+
import { defaultInterruptPollingConfig } from '../types/interrupt.js';
|
|
11
|
+
import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
|
|
12
|
+
import { getEndpointConfig } from './api.js';
|
|
13
|
+
/**
|
|
14
|
+
* Interrupt Service class
|
|
15
|
+
*
|
|
16
|
+
* Provides methods to interact with interrupt API endpoints including
|
|
17
|
+
* fetching, resolving, cancelling, and listing interrupts.
|
|
18
|
+
* Supports optional dedicated polling for interrupt status.
|
|
19
|
+
*/
|
|
20
|
+
export class InterruptService {
|
|
21
|
+
static instance;
|
|
22
|
+
pollingInterval = null;
|
|
23
|
+
pollingSessionId = null;
|
|
24
|
+
currentBackoff;
|
|
25
|
+
pollingConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Private constructor for singleton pattern
|
|
28
|
+
*/
|
|
29
|
+
constructor() {
|
|
30
|
+
this.pollingConfig = { ...defaultInterruptPollingConfig };
|
|
31
|
+
this.currentBackoff = this.pollingConfig.interval ?? 2000;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the singleton instance of InterruptService
|
|
35
|
+
*
|
|
36
|
+
* @returns The InterruptService singleton instance
|
|
37
|
+
*/
|
|
38
|
+
static getInstance() {
|
|
39
|
+
if (!InterruptService.instance) {
|
|
40
|
+
InterruptService.instance = new InterruptService();
|
|
41
|
+
}
|
|
42
|
+
return InterruptService.instance;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Configure interrupt polling settings
|
|
46
|
+
*
|
|
47
|
+
* @param config - Polling configuration options
|
|
48
|
+
*/
|
|
49
|
+
setPollingConfig(config) {
|
|
50
|
+
this.pollingConfig = { ...this.pollingConfig, ...config };
|
|
51
|
+
this.currentBackoff = this.pollingConfig.interval ?? 2000;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the current polling configuration
|
|
55
|
+
*
|
|
56
|
+
* @returns Current polling configuration
|
|
57
|
+
*/
|
|
58
|
+
getPollingConfig() {
|
|
59
|
+
return { ...this.pollingConfig };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if interrupt endpoints are configured
|
|
63
|
+
*
|
|
64
|
+
* @returns True if interrupt endpoints are available
|
|
65
|
+
*/
|
|
66
|
+
isConfigured() {
|
|
67
|
+
const config = getEndpointConfig();
|
|
68
|
+
return Boolean(config?.endpoints?.interrupts);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the endpoint configuration
|
|
72
|
+
*
|
|
73
|
+
* @throws Error if endpoint configuration is not set
|
|
74
|
+
* @returns The endpoint configuration
|
|
75
|
+
*/
|
|
76
|
+
getConfig() {
|
|
77
|
+
const config = getEndpointConfig();
|
|
78
|
+
if (!config) {
|
|
79
|
+
throw new Error('Endpoint configuration not set. Call setEndpointConfig() first.');
|
|
80
|
+
}
|
|
81
|
+
if (!config.endpoints.interrupts) {
|
|
82
|
+
throw new Error('Interrupt endpoints not configured.');
|
|
83
|
+
}
|
|
84
|
+
return config;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generic API request helper
|
|
88
|
+
*
|
|
89
|
+
* @param url - The URL to fetch
|
|
90
|
+
* @param options - Fetch options
|
|
91
|
+
* @returns The parsed JSON response
|
|
92
|
+
*/
|
|
93
|
+
async request(url, options = {}) {
|
|
94
|
+
const config = this.getConfig();
|
|
95
|
+
const headers = getEndpointHeaders(config, 'interrupts');
|
|
96
|
+
const response = await fetch(url, {
|
|
97
|
+
...options,
|
|
98
|
+
headers: {
|
|
99
|
+
...headers,
|
|
100
|
+
...options.headers
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
const errorData = await response.json().catch(() => ({}));
|
|
105
|
+
const errorMessage = errorData.error ||
|
|
106
|
+
errorData.message ||
|
|
107
|
+
`HTTP ${response.status}: ${response.statusText}`;
|
|
108
|
+
throw new Error(errorMessage);
|
|
109
|
+
}
|
|
110
|
+
return response.json();
|
|
111
|
+
}
|
|
112
|
+
// =========================================================================
|
|
113
|
+
// Interrupt Operations
|
|
114
|
+
// =========================================================================
|
|
115
|
+
/**
|
|
116
|
+
* Get interrupt details by ID
|
|
117
|
+
*
|
|
118
|
+
* @param interruptId - The interrupt UUID
|
|
119
|
+
* @returns The interrupt details
|
|
120
|
+
*/
|
|
121
|
+
async getInterrupt(interruptId) {
|
|
122
|
+
const config = this.getConfig();
|
|
123
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.get, {
|
|
124
|
+
interruptId
|
|
125
|
+
});
|
|
126
|
+
const response = await this.request(url);
|
|
127
|
+
if (!response.data) {
|
|
128
|
+
throw new Error('Interrupt not found');
|
|
129
|
+
}
|
|
130
|
+
return response.data;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolve an interrupt with user response
|
|
134
|
+
*
|
|
135
|
+
* @param interruptId - The interrupt UUID
|
|
136
|
+
* @param value - The user's response value
|
|
137
|
+
* @returns The updated interrupt
|
|
138
|
+
*/
|
|
139
|
+
async resolveInterrupt(interruptId, value) {
|
|
140
|
+
const config = this.getConfig();
|
|
141
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.resolve, {
|
|
142
|
+
interruptId
|
|
143
|
+
});
|
|
144
|
+
const resolution = { value };
|
|
145
|
+
const response = await this.request(url, {
|
|
146
|
+
method: 'POST',
|
|
147
|
+
body: JSON.stringify(resolution)
|
|
148
|
+
});
|
|
149
|
+
if (!response.data) {
|
|
150
|
+
throw new Error('Failed to resolve interrupt: No data returned');
|
|
151
|
+
}
|
|
152
|
+
return response.data;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Cancel a pending interrupt
|
|
156
|
+
*
|
|
157
|
+
* @param interruptId - The interrupt UUID
|
|
158
|
+
* @returns The updated interrupt
|
|
159
|
+
*/
|
|
160
|
+
async cancelInterrupt(interruptId) {
|
|
161
|
+
const config = this.getConfig();
|
|
162
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.cancel, {
|
|
163
|
+
interruptId
|
|
164
|
+
});
|
|
165
|
+
const response = await this.request(url, {
|
|
166
|
+
method: 'POST'
|
|
167
|
+
});
|
|
168
|
+
if (!response.data) {
|
|
169
|
+
throw new Error('Failed to cancel interrupt: No data returned');
|
|
170
|
+
}
|
|
171
|
+
return response.data;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* List interrupts for a playground session
|
|
175
|
+
*
|
|
176
|
+
* @param sessionId - The session UUID
|
|
177
|
+
* @returns Array of interrupts for the session
|
|
178
|
+
*/
|
|
179
|
+
async listSessionInterrupts(sessionId) {
|
|
180
|
+
const config = this.getConfig();
|
|
181
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.listBySession, {
|
|
182
|
+
sessionId
|
|
183
|
+
});
|
|
184
|
+
const response = await this.request(url);
|
|
185
|
+
return response.data ?? [];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* List interrupts for a pipeline
|
|
189
|
+
*
|
|
190
|
+
* @param pipelineId - The pipeline UUID
|
|
191
|
+
* @returns Array of interrupts for the pipeline
|
|
192
|
+
*/
|
|
193
|
+
async listPipelineInterrupts(pipelineId) {
|
|
194
|
+
const config = this.getConfig();
|
|
195
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.listByPipeline, {
|
|
196
|
+
pipelineId
|
|
197
|
+
});
|
|
198
|
+
const response = await this.request(url);
|
|
199
|
+
return response.data ?? [];
|
|
200
|
+
}
|
|
201
|
+
// =========================================================================
|
|
202
|
+
// Polling (Optional)
|
|
203
|
+
// =========================================================================
|
|
204
|
+
/**
|
|
205
|
+
* Start polling for interrupts in a session
|
|
206
|
+
*
|
|
207
|
+
* This is optional - interrupts are typically detected via message metadata.
|
|
208
|
+
* Use this for scenarios where dedicated polling is preferred.
|
|
209
|
+
*
|
|
210
|
+
* @param sessionId - The session UUID to poll
|
|
211
|
+
* @param callback - Callback function to handle new interrupts
|
|
212
|
+
*/
|
|
213
|
+
startPolling(sessionId, callback) {
|
|
214
|
+
if (!this.pollingConfig.enabled) {
|
|
215
|
+
console.warn('[InterruptService] Polling is disabled. Enable via setPollingConfig().');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// Stop any existing polling
|
|
219
|
+
this.stopPolling();
|
|
220
|
+
this.pollingSessionId = sessionId;
|
|
221
|
+
this.currentBackoff = this.pollingConfig.interval ?? 2000;
|
|
222
|
+
const poll = async () => {
|
|
223
|
+
if (this.pollingSessionId !== sessionId) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
const interrupts = await this.listSessionInterrupts(sessionId);
|
|
228
|
+
const pendingInterrupts = interrupts.filter((i) => i.status === 'pending');
|
|
229
|
+
// Reset backoff on successful request
|
|
230
|
+
this.currentBackoff = this.pollingConfig.interval ?? 2000;
|
|
231
|
+
// Call the callback with pending interrupts
|
|
232
|
+
callback(pendingInterrupts);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error('[InterruptService] Polling error:', error);
|
|
236
|
+
// Exponential backoff on error
|
|
237
|
+
const maxBackoff = this.pollingConfig.maxBackoff ?? 10000;
|
|
238
|
+
this.currentBackoff = Math.min(this.currentBackoff * 2, maxBackoff);
|
|
239
|
+
}
|
|
240
|
+
// Schedule next poll
|
|
241
|
+
if (this.pollingSessionId === sessionId) {
|
|
242
|
+
this.pollingInterval = setTimeout(poll, this.currentBackoff);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
// Start polling immediately
|
|
246
|
+
void poll();
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Stop polling for interrupts
|
|
250
|
+
*/
|
|
251
|
+
stopPolling() {
|
|
252
|
+
if (this.pollingInterval) {
|
|
253
|
+
clearTimeout(this.pollingInterval);
|
|
254
|
+
this.pollingInterval = null;
|
|
255
|
+
}
|
|
256
|
+
this.pollingSessionId = null;
|
|
257
|
+
this.currentBackoff = this.pollingConfig.interval ?? 2000;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Check if polling is active
|
|
261
|
+
*
|
|
262
|
+
* @returns True if polling is active
|
|
263
|
+
*/
|
|
264
|
+
isPolling() {
|
|
265
|
+
return this.pollingSessionId !== null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Get the current polling session ID
|
|
269
|
+
*
|
|
270
|
+
* @returns The session ID being polled, or null
|
|
271
|
+
*/
|
|
272
|
+
getPollingSessionId() {
|
|
273
|
+
return this.pollingSessionId;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Export singleton instance
|
|
278
|
+
*/
|
|
279
|
+
export const interruptService = InterruptService.getInstance();
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interrupt Store
|
|
3
|
+
*
|
|
4
|
+
* Svelte stores for managing interrupt state using a lightweight state machine.
|
|
5
|
+
* Ensures valid state transitions and prevents deadlocks.
|
|
6
|
+
*
|
|
7
|
+
* @module stores/interruptStore
|
|
8
|
+
*/
|
|
9
|
+
import type { Interrupt, InterruptStatus } from '../types/interrupt.js';
|
|
10
|
+
import { type InterruptState, type TransitionResult } from '../types/interruptState.js';
|
|
11
|
+
/**
|
|
12
|
+
* Extended interrupt with state machine
|
|
13
|
+
*/
|
|
14
|
+
export interface InterruptWithState extends Interrupt {
|
|
15
|
+
/** State machine state for UI interaction tracking */
|
|
16
|
+
machineState: InterruptState;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Map of all interrupts by ID
|
|
20
|
+
* Key: interrupt ID, Value: Interrupt object with state
|
|
21
|
+
*/
|
|
22
|
+
export declare const interrupts: import("svelte/store").Writable<Map<string, InterruptWithState>>;
|
|
23
|
+
/**
|
|
24
|
+
* Derived store for pending interrupt IDs
|
|
25
|
+
*/
|
|
26
|
+
export declare const pendingInterruptIds: import("svelte/store").Readable<string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Derived store for pending interrupts array
|
|
29
|
+
*/
|
|
30
|
+
export declare const pendingInterrupts: import("svelte/store").Readable<InterruptWithState[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Derived store for count of pending interrupts
|
|
33
|
+
*/
|
|
34
|
+
export declare const pendingInterruptCount: import("svelte/store").Readable<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Derived store for resolved interrupts
|
|
37
|
+
*/
|
|
38
|
+
export declare const resolvedInterrupts: import("svelte/store").Readable<InterruptWithState[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Derived store to check if any interrupt is currently submitting
|
|
41
|
+
*/
|
|
42
|
+
export declare const isAnySubmitting: import("svelte/store").Readable<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Legacy derived store for submitting interrupt IDs
|
|
45
|
+
* @deprecated Use interrupt.machineState.status === "submitting" instead
|
|
46
|
+
*/
|
|
47
|
+
export declare const submittingInterrupts: import("svelte/store").Readable<Set<string>>;
|
|
48
|
+
/**
|
|
49
|
+
* Legacy derived store for interrupt errors
|
|
50
|
+
* @deprecated Use interrupt.machineState.error instead
|
|
51
|
+
*/
|
|
52
|
+
export declare const interruptErrors: import("svelte/store").Readable<Map<string, string>>;
|
|
53
|
+
/**
|
|
54
|
+
* Interrupt store actions for modifying state
|
|
55
|
+
*/
|
|
56
|
+
export declare const interruptActions: {
|
|
57
|
+
/**
|
|
58
|
+
* Add or update an interrupt in the store
|
|
59
|
+
*
|
|
60
|
+
* @param interrupt - The interrupt to add or update
|
|
61
|
+
*/
|
|
62
|
+
addInterrupt: (interrupt: Interrupt) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Add multiple interrupts to the store
|
|
65
|
+
*
|
|
66
|
+
* @param interruptList - Array of interrupts to add
|
|
67
|
+
*/
|
|
68
|
+
addInterrupts: (interruptList: Interrupt[]) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Start submitting an interrupt (user clicked submit)
|
|
71
|
+
*
|
|
72
|
+
* @param interruptId - The interrupt ID
|
|
73
|
+
* @param value - The value being submitted
|
|
74
|
+
* @returns Transition result
|
|
75
|
+
*/
|
|
76
|
+
startSubmit: (interruptId: string, value: unknown) => TransitionResult;
|
|
77
|
+
/**
|
|
78
|
+
* Start cancelling an interrupt (user clicked cancel)
|
|
79
|
+
*
|
|
80
|
+
* @param interruptId - The interrupt ID
|
|
81
|
+
* @returns Transition result
|
|
82
|
+
*/
|
|
83
|
+
startCancel: (interruptId: string) => TransitionResult;
|
|
84
|
+
/**
|
|
85
|
+
* Mark submission as successful
|
|
86
|
+
*
|
|
87
|
+
* @param interruptId - The interrupt ID
|
|
88
|
+
* @returns Transition result
|
|
89
|
+
*/
|
|
90
|
+
submitSuccess: (interruptId: string) => TransitionResult;
|
|
91
|
+
/**
|
|
92
|
+
* Mark submission as failed
|
|
93
|
+
*
|
|
94
|
+
* @param interruptId - The interrupt ID
|
|
95
|
+
* @param error - Error message
|
|
96
|
+
* @returns Transition result
|
|
97
|
+
*/
|
|
98
|
+
submitFailure: (interruptId: string, error: string) => TransitionResult;
|
|
99
|
+
/**
|
|
100
|
+
* Retry a failed submission
|
|
101
|
+
*
|
|
102
|
+
* @param interruptId - The interrupt ID
|
|
103
|
+
* @returns Transition result
|
|
104
|
+
*/
|
|
105
|
+
retry: (interruptId: string) => TransitionResult;
|
|
106
|
+
/**
|
|
107
|
+
* Reset an interrupt to idle state
|
|
108
|
+
*
|
|
109
|
+
* @param interruptId - The interrupt ID
|
|
110
|
+
* @returns Transition result
|
|
111
|
+
*/
|
|
112
|
+
resetInterrupt: (interruptId: string) => TransitionResult;
|
|
113
|
+
/**
|
|
114
|
+
* Update an interrupt's status (legacy)
|
|
115
|
+
* @deprecated Use startSubmit/submitSuccess/submitFailure instead
|
|
116
|
+
*/
|
|
117
|
+
updateStatus: (interruptId: string, status: InterruptStatus, responseValue?: unknown) => void;
|
|
118
|
+
/**
|
|
119
|
+
* Mark an interrupt as resolved with the user's response (legacy)
|
|
120
|
+
* @deprecated Use startSubmit + submitSuccess instead
|
|
121
|
+
*/
|
|
122
|
+
resolveInterrupt: (interruptId: string, value: unknown) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Mark an interrupt as cancelled (legacy)
|
|
125
|
+
* @deprecated Use startCancel + submitSuccess instead
|
|
126
|
+
*/
|
|
127
|
+
cancelInterrupt: (interruptId: string) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Set submitting state for an interrupt (legacy)
|
|
130
|
+
* @deprecated State is automatically managed by startSubmit/submitSuccess
|
|
131
|
+
*/
|
|
132
|
+
setSubmitting: (interruptId: string, isSubmitting: boolean) => void;
|
|
133
|
+
/**
|
|
134
|
+
* Set error for an interrupt (legacy)
|
|
135
|
+
* @deprecated Use submitFailure() instead
|
|
136
|
+
*/
|
|
137
|
+
setError: (interruptId: string, error: string | null) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Remove an interrupt from the store
|
|
140
|
+
*
|
|
141
|
+
* @param interruptId - The interrupt ID to remove
|
|
142
|
+
*/
|
|
143
|
+
removeInterrupt: (interruptId: string) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Clear all interrupts for a specific session
|
|
146
|
+
*
|
|
147
|
+
* @param sessionId - The session ID to clear interrupts for
|
|
148
|
+
*/
|
|
149
|
+
clearSessionInterrupts: (sessionId: string) => void;
|
|
150
|
+
/**
|
|
151
|
+
* Alias for clearSessionInterrupts
|
|
152
|
+
*/
|
|
153
|
+
clearInterrupts: () => void;
|
|
154
|
+
/**
|
|
155
|
+
* Reset all interrupt state
|
|
156
|
+
*/
|
|
157
|
+
reset: () => void;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Get an interrupt by ID
|
|
161
|
+
*
|
|
162
|
+
* @param interruptId - The interrupt ID
|
|
163
|
+
* @returns The interrupt or undefined
|
|
164
|
+
*/
|
|
165
|
+
export declare function getInterrupt(interruptId: string): InterruptWithState | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Check if an interrupt is pending (not resolved or cancelled)
|
|
168
|
+
*
|
|
169
|
+
* @param interruptId - The interrupt ID
|
|
170
|
+
* @returns True if the interrupt exists and is pending
|
|
171
|
+
*/
|
|
172
|
+
export declare function isInterruptPending(interruptId: string): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Check if an interrupt is currently submitting
|
|
175
|
+
*
|
|
176
|
+
* @param interruptId - The interrupt ID
|
|
177
|
+
* @returns True if the interrupt is being submitted
|
|
178
|
+
*/
|
|
179
|
+
export declare function isInterruptSubmitting(interruptId: string): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Get the error for an interrupt
|
|
182
|
+
*
|
|
183
|
+
* @param interruptId - The interrupt ID
|
|
184
|
+
* @returns The error message or undefined
|
|
185
|
+
*/
|
|
186
|
+
export declare function getInterruptError(interruptId: string): string | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Get an interrupt by its associated message ID
|
|
189
|
+
*
|
|
190
|
+
* @param messageId - The message ID
|
|
191
|
+
* @returns The interrupt or undefined
|
|
192
|
+
*/
|
|
193
|
+
export declare function getInterruptByMessageId(messageId: string): InterruptWithState | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Check if an interrupt has an error
|
|
196
|
+
*
|
|
197
|
+
* @param interruptId - The interrupt ID
|
|
198
|
+
* @returns True if the interrupt has an error
|
|
199
|
+
*/
|
|
200
|
+
export declare function interruptHasError(interruptId: string): boolean;
|