cloudcruise 0.0.3 → 0.0.4
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/dist/events/types.d.ts +152 -0
- package/dist/events/types.js +22 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/runs/RunsClient.js +10 -2
- package/dist/runs/types.d.ts +23 -17
- package/dist/utils/connectionManager.js +13 -3
- package/dist/utils/events.d.ts +20 -3
- package/dist/utils/events.js +17 -0
- package/dist/webhook/WebhookClient.d.ts +3 -2
- package/dist/webhook/types.d.ts +0 -108
- package/dist/webhook/types.js +0 -13
- package/dist/webhook/utils.d.ts +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Event Type Definitions
|
|
3
|
+
* Used by both Webhook and SSE Run event handlers
|
|
4
|
+
*/
|
|
5
|
+
export declare enum EventType {
|
|
6
|
+
ExecutionQueued = "execution.queued",
|
|
7
|
+
ExecutionStart = "execution.start",
|
|
8
|
+
ExecutionStep = "execution.step",
|
|
9
|
+
ExecutionPause = "execution.pause",
|
|
10
|
+
ExecutionStopped = "execution.stopped",
|
|
11
|
+
ExecutionFailed = "execution.failed",
|
|
12
|
+
ExecutionSuccess = "execution.success",
|
|
13
|
+
ExecutionRequeued = "execution.requeued",
|
|
14
|
+
FileUploaded = "file.uploaded",
|
|
15
|
+
ScreenshotUploaded = "screenshot.uploaded",
|
|
16
|
+
VideoUploaded = "video.uploaded",
|
|
17
|
+
InteractionWaiting = "interaction.waiting",
|
|
18
|
+
InteractionFinished = "interaction.finished",
|
|
19
|
+
InteractionFailed = "interaction.failed",
|
|
20
|
+
AgentErrorAnalysis = "agent.error_analysis"
|
|
21
|
+
}
|
|
22
|
+
export interface ExecutionQueuedPayload {
|
|
23
|
+
session_id: string;
|
|
24
|
+
workflow_id: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ExecutionStartPayload {
|
|
27
|
+
session_id: string;
|
|
28
|
+
workflow_id: string;
|
|
29
|
+
live_view_url?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ExecutionStepPayload {
|
|
32
|
+
session_id: string;
|
|
33
|
+
workflow_id: string;
|
|
34
|
+
current_step: string;
|
|
35
|
+
next_step: string;
|
|
36
|
+
}
|
|
37
|
+
export interface InteractionWaitingPayload {
|
|
38
|
+
session_id: string;
|
|
39
|
+
workflow_id: string;
|
|
40
|
+
current_step: string;
|
|
41
|
+
missing_properties: string[];
|
|
42
|
+
expected_json_schema_datamodel: Record<string, any>;
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
export type InteractionFinishedPayload = {
|
|
46
|
+
session_id: string;
|
|
47
|
+
workflow_id: string;
|
|
48
|
+
current_step: string;
|
|
49
|
+
missing_properties: [];
|
|
50
|
+
expected_json_schema_datamodel: Record<string, any>;
|
|
51
|
+
message: string;
|
|
52
|
+
} | {
|
|
53
|
+
session_id: string;
|
|
54
|
+
workflow_id: string;
|
|
55
|
+
provided_input: any;
|
|
56
|
+
message?: string;
|
|
57
|
+
expected_json_schema_datamodel: Record<string, any>;
|
|
58
|
+
};
|
|
59
|
+
export interface AgentErrorAnalysisPayload {
|
|
60
|
+
analysis_step_name: string;
|
|
61
|
+
ai_analysis?: string;
|
|
62
|
+
root_cause_analysis?: string;
|
|
63
|
+
error_category?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ExecutionRequeuedPayload {
|
|
66
|
+
session_id: string;
|
|
67
|
+
workflow_id: string;
|
|
68
|
+
retry_attempt: number;
|
|
69
|
+
max_retries?: number;
|
|
70
|
+
next_execution_time: string;
|
|
71
|
+
delay_ms: number;
|
|
72
|
+
}
|
|
73
|
+
export interface EndRunError {
|
|
74
|
+
message: string;
|
|
75
|
+
error_id: string;
|
|
76
|
+
full_url?: string;
|
|
77
|
+
created_at: string;
|
|
78
|
+
error_code?: string;
|
|
79
|
+
action_type?: string;
|
|
80
|
+
action_display_name?: string;
|
|
81
|
+
llm_error_category?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface EndRunPayload {
|
|
84
|
+
session_id: string;
|
|
85
|
+
workflow_id: string;
|
|
86
|
+
data: any;
|
|
87
|
+
input_variables: Record<string, any>;
|
|
88
|
+
errors: EndRunError[];
|
|
89
|
+
status: EventType.ExecutionSuccess | EventType.ExecutionFailed | EventType.ExecutionStopped;
|
|
90
|
+
encrypted_variables: string[] | null;
|
|
91
|
+
file_urls: any[] | null;
|
|
92
|
+
}
|
|
93
|
+
export interface ExecutionStoppedEarlyPayload {
|
|
94
|
+
message: string;
|
|
95
|
+
error_code: string;
|
|
96
|
+
session_id: string;
|
|
97
|
+
}
|
|
98
|
+
export interface FileUploadedPayload {
|
|
99
|
+
signed_file_url: string;
|
|
100
|
+
file_name: string;
|
|
101
|
+
timestamp: string;
|
|
102
|
+
signed_file_url_expires: string;
|
|
103
|
+
metadata: Record<string, any>;
|
|
104
|
+
session_id: string;
|
|
105
|
+
}
|
|
106
|
+
export interface ScreenshotUploadedPayload {
|
|
107
|
+
screenshot_id: string;
|
|
108
|
+
signed_screenshot_url: string;
|
|
109
|
+
node_display_name: string;
|
|
110
|
+
node_id: string;
|
|
111
|
+
timestamp: string;
|
|
112
|
+
signed_screenshot_url_expires: string;
|
|
113
|
+
error_screenshot: boolean;
|
|
114
|
+
retry_index: number;
|
|
115
|
+
full_length_screenshot: boolean;
|
|
116
|
+
session_id: string;
|
|
117
|
+
}
|
|
118
|
+
export type EventPayloadMap = {
|
|
119
|
+
[EventType.ExecutionQueued]: ExecutionQueuedPayload;
|
|
120
|
+
[EventType.ExecutionStart]: ExecutionStartPayload;
|
|
121
|
+
[EventType.ExecutionStep]: ExecutionStepPayload;
|
|
122
|
+
[EventType.InteractionWaiting]: InteractionWaitingPayload;
|
|
123
|
+
[EventType.InteractionFinished]: InteractionFinishedPayload;
|
|
124
|
+
[EventType.AgentErrorAnalysis]: AgentErrorAnalysisPayload;
|
|
125
|
+
[EventType.ExecutionRequeued]: ExecutionRequeuedPayload;
|
|
126
|
+
[EventType.ExecutionSuccess]: EndRunPayload;
|
|
127
|
+
[EventType.ExecutionFailed]: EndRunPayload;
|
|
128
|
+
[EventType.ExecutionStopped]: EndRunPayload | ExecutionStoppedEarlyPayload;
|
|
129
|
+
[EventType.FileUploaded]: FileUploadedPayload;
|
|
130
|
+
[EventType.ScreenshotUploaded]: ScreenshotUploadedPayload;
|
|
131
|
+
[EventType.VideoUploaded]: never;
|
|
132
|
+
[EventType.ExecutionPause]: never;
|
|
133
|
+
[EventType.InteractionFailed]: never;
|
|
134
|
+
};
|
|
135
|
+
export type WebhookMessage<E extends EventType = EventType> = {
|
|
136
|
+
event: E;
|
|
137
|
+
timestamp: number;
|
|
138
|
+
expires_at: number;
|
|
139
|
+
payload: EventPayloadMap[E];
|
|
140
|
+
metadata?: Record<string, any>;
|
|
141
|
+
};
|
|
142
|
+
export type RunEventMessage<E extends EventType = EventType> = {
|
|
143
|
+
event: "run.event";
|
|
144
|
+
data: {
|
|
145
|
+
event: E;
|
|
146
|
+
payload: EventPayloadMap[E];
|
|
147
|
+
timestamp: number;
|
|
148
|
+
expires_at: number;
|
|
149
|
+
};
|
|
150
|
+
timestamp: string;
|
|
151
|
+
expires_at: string;
|
|
152
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Event Type Definitions
|
|
3
|
+
* Used by both Webhook and SSE Run event handlers
|
|
4
|
+
*/
|
|
5
|
+
export var EventType;
|
|
6
|
+
(function (EventType) {
|
|
7
|
+
EventType["ExecutionQueued"] = "execution.queued";
|
|
8
|
+
EventType["ExecutionStart"] = "execution.start";
|
|
9
|
+
EventType["ExecutionStep"] = "execution.step";
|
|
10
|
+
EventType["ExecutionPause"] = "execution.pause";
|
|
11
|
+
EventType["ExecutionStopped"] = "execution.stopped";
|
|
12
|
+
EventType["ExecutionFailed"] = "execution.failed";
|
|
13
|
+
EventType["ExecutionSuccess"] = "execution.success";
|
|
14
|
+
EventType["ExecutionRequeued"] = "execution.requeued";
|
|
15
|
+
EventType["FileUploaded"] = "file.uploaded";
|
|
16
|
+
EventType["ScreenshotUploaded"] = "screenshot.uploaded";
|
|
17
|
+
EventType["VideoUploaded"] = "video.uploaded";
|
|
18
|
+
EventType["InteractionWaiting"] = "interaction.waiting";
|
|
19
|
+
EventType["InteractionFinished"] = "interaction.finished";
|
|
20
|
+
EventType["InteractionFailed"] = "interaction.failed";
|
|
21
|
+
EventType["AgentErrorAnalysis"] = "agent.error_analysis";
|
|
22
|
+
})(EventType || (EventType = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,9 @@ export { RunsClient } from './runs/RunsClient.js';
|
|
|
10
10
|
export { WebhookClient } from './webhook/WebhookClient.js';
|
|
11
11
|
export type { VaultEntry, GetVaultEntriesFilters, ProxyConfig, VaultPostPutHeadersInBody } from './vault/types.js';
|
|
12
12
|
export type { Workflow, WorkflowInputSchema, WorkflowMetadata } from './workflows/types.js';
|
|
13
|
-
export type {
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
13
|
+
export type { DryRun, Metadata, RunSpecificWebhook, PayloadWebhook, StartRunRequest, StartRunResponse, UserInteractionData, VideoUrl, SignedFileUrl, SignedScreenshotUrl, RunError, WorkflowError, RunResult, GetRunResult, WebhookEvent, WebhookReplayResponse, RunHandle, RunStreamOptions, SseEventName, SseMessage, RunEventEnvelope, RunHandleEventMap } from './runs/types.js';
|
|
14
|
+
export { EventType } from './events/types.js';
|
|
15
|
+
export type { WebhookMessage, RunEventMessage } from './events/types.js';
|
|
16
|
+
export type { WebhookVerificationOptions } from './webhook/types.js';
|
|
16
17
|
export { VerificationError } from './webhook/types.js';
|
|
17
18
|
export { InputValidationError } from './workflows/types.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { VaultClient } from './vault/VaultClient.js';
|
|
|
7
7
|
export { WorkflowsClient } from './workflows/WorkflowsClient.js';
|
|
8
8
|
export { RunsClient } from './runs/RunsClient.js';
|
|
9
9
|
export { WebhookClient } from './webhook/WebhookClient.js';
|
|
10
|
-
|
|
10
|
+
// Export shared event types
|
|
11
|
+
export { EventType } from './events/types.js';
|
|
11
12
|
export { VerificationError } from './webhook/types.js';
|
|
12
13
|
export { InputValidationError } from './workflows/types.js';
|
package/dist/runs/RunsClient.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EventType } from '../events/types.js';
|
|
1
2
|
import { AsyncEventQueue } from '../utils/asyncQueue.js';
|
|
2
3
|
import { SimpleEventEmitter } from '../utils/events.js';
|
|
3
4
|
export class RunsClient {
|
|
@@ -37,7 +38,9 @@ export class RunsClient {
|
|
|
37
38
|
enabled: options?.reconnect?.enabled ?? true,
|
|
38
39
|
delays: options?.reconnect?.delays ?? [1000, 3000, 10000],
|
|
39
40
|
};
|
|
40
|
-
const isTerminalEvent = (status) => status ===
|
|
41
|
+
const isTerminalEvent = (status) => status === EventType.ExecutionSuccess ||
|
|
42
|
+
status === EventType.ExecutionFailed ||
|
|
43
|
+
status === EventType.ExecutionStopped;
|
|
41
44
|
const emit = (event, payload) => {
|
|
42
45
|
emitter.emit(event, payload);
|
|
43
46
|
// Mirror only SSE messages to 'message' for catch-all consumers
|
|
@@ -69,6 +72,11 @@ export class RunsClient {
|
|
|
69
72
|
return;
|
|
70
73
|
stream.push(sseMsg);
|
|
71
74
|
emit('run.event', sseMsg);
|
|
75
|
+
// Emit typed per-event key for better DX
|
|
76
|
+
try {
|
|
77
|
+
emitter.emit(sseMsg.data.event, sseMsg);
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
72
80
|
const eventType = sseMsg.data.event;
|
|
73
81
|
if (typeof eventType === 'string' && isTerminalEvent(eventType)) {
|
|
74
82
|
endAndCleanup(eventType);
|
|
@@ -107,7 +115,7 @@ export class RunsClient {
|
|
|
107
115
|
}
|
|
108
116
|
else {
|
|
109
117
|
// End without explicit type; still clean up
|
|
110
|
-
endAndCleanup(
|
|
118
|
+
endAndCleanup(EventType.ExecutionStopped);
|
|
111
119
|
}
|
|
112
120
|
});
|
|
113
121
|
};
|
package/dist/runs/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CloudCruise Runs API Type Definitions
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import type { EventType, RunEventMessage, EventPayloadMap, ExecutionQueuedPayload, ExecutionStartPayload, ExecutionStepPayload, InteractionWaitingPayload, InteractionFinishedPayload, AgentErrorAnalysisPayload, ExecutionRequeuedPayload, EndRunPayload, EndRunError, ExecutionStoppedEarlyPayload, FileUploadedPayload, ScreenshotUploadedPayload } from '../events/types.js';
|
|
5
|
+
export type { EventType };
|
|
6
|
+
export type { ExecutionQueuedPayload, ExecutionStartPayload, ExecutionStepPayload, InteractionWaitingPayload, InteractionFinishedPayload, AgentErrorAnalysisPayload, ExecutionRequeuedPayload, EndRunPayload, EndRunError, ExecutionStoppedEarlyPayload, FileUploadedPayload, ScreenshotUploadedPayload, EventPayloadMap, };
|
|
5
7
|
export interface DryRun {
|
|
6
8
|
enabled: boolean;
|
|
7
9
|
add_to_output?: Record<string, any>;
|
|
@@ -109,27 +111,14 @@ export interface WebhookReplayResponse {
|
|
|
109
111
|
* Streaming (SSE) types
|
|
110
112
|
*/
|
|
111
113
|
export type SseEventName = 'run.event' | 'ping';
|
|
112
|
-
export
|
|
113
|
-
event: 'run.event';
|
|
114
|
-
data: {
|
|
115
|
-
event: EventType | string;
|
|
116
|
-
payload: {
|
|
117
|
-
session_id: string;
|
|
118
|
-
[key: string]: any;
|
|
119
|
-
};
|
|
120
|
-
expires_at: number;
|
|
121
|
-
timestamp: number;
|
|
122
|
-
};
|
|
123
|
-
timestamp?: string;
|
|
124
|
-
expires_at?: string;
|
|
125
|
-
}
|
|
114
|
+
export type RunEventEnvelope<E extends EventType = EventType> = RunEventMessage<E>;
|
|
126
115
|
export interface PingEnvelope {
|
|
127
116
|
event: 'ping';
|
|
128
117
|
data: {
|
|
129
118
|
ts: number;
|
|
130
119
|
} | Record<string, any>;
|
|
131
120
|
}
|
|
132
|
-
export type SseMessage = RunEventEnvelope | PingEnvelope;
|
|
121
|
+
export type SseMessage<E extends EventType = EventType> = RunEventEnvelope<E> | PingEnvelope;
|
|
133
122
|
export interface RunStreamOptions {
|
|
134
123
|
signal?: AbortSignal;
|
|
135
124
|
withCredentials?: boolean;
|
|
@@ -140,9 +129,26 @@ export interface RunStreamOptions {
|
|
|
140
129
|
jitter?: number;
|
|
141
130
|
};
|
|
142
131
|
}
|
|
132
|
+
export type RunEventMap = {
|
|
133
|
+
[K in EventType]: RunEventEnvelope<K>;
|
|
134
|
+
};
|
|
135
|
+
export type RunHandleEventMap = {
|
|
136
|
+
'open': undefined;
|
|
137
|
+
'close': undefined;
|
|
138
|
+
'reconnect': {
|
|
139
|
+
attemptDelayMs: number;
|
|
140
|
+
};
|
|
141
|
+
'error': unknown;
|
|
142
|
+
'end': {
|
|
143
|
+
type: EventType;
|
|
144
|
+
};
|
|
145
|
+
'run.event': SseMessage;
|
|
146
|
+
'ping': PingEnvelope;
|
|
147
|
+
'message': SseMessage | PingEnvelope;
|
|
148
|
+
} & RunEventMap;
|
|
143
149
|
export interface RunHandle {
|
|
144
150
|
sessionId: string;
|
|
145
|
-
on(event:
|
|
151
|
+
on<K extends keyof RunHandleEventMap>(event: K, handler: (e: RunHandleEventMap[K]) => void): () => void;
|
|
146
152
|
wait(): Promise<GetRunResult>;
|
|
147
153
|
close(): void;
|
|
148
154
|
[Symbol.asyncIterator](): AsyncIterator<SseMessage>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { openSSE } from './sse.js';
|
|
2
2
|
import { SimpleEventEmitter } from './events.js';
|
|
3
3
|
import { AsyncEventQueue } from './asyncQueue.js';
|
|
4
|
+
import { EventType } from '../events/types.js';
|
|
4
5
|
function isFinalEvent(eventType) {
|
|
5
|
-
return eventType ===
|
|
6
|
+
return (eventType === EventType.ExecutionSuccess ||
|
|
7
|
+
eventType === EventType.ExecutionFailed ||
|
|
8
|
+
eventType === EventType.ExecutionStopped);
|
|
6
9
|
}
|
|
7
10
|
export class ConnectionManager {
|
|
8
11
|
baseUrl;
|
|
@@ -144,7 +147,9 @@ export class ConnectionManager {
|
|
|
144
147
|
if (!data) {
|
|
145
148
|
return;
|
|
146
149
|
}
|
|
147
|
-
|
|
150
|
+
// Extract session_id - it's always present in payload
|
|
151
|
+
const payload = data.payload;
|
|
152
|
+
const sessionId = payload?.session_id;
|
|
148
153
|
if (!sessionId) {
|
|
149
154
|
return;
|
|
150
155
|
}
|
|
@@ -152,7 +157,12 @@ export class ConnectionManager {
|
|
|
152
157
|
if (!channel) {
|
|
153
158
|
return;
|
|
154
159
|
}
|
|
155
|
-
const msg = {
|
|
160
|
+
const msg = {
|
|
161
|
+
event: 'run.event',
|
|
162
|
+
data: data,
|
|
163
|
+
timestamp: raw.timestamp || new Date().toISOString(),
|
|
164
|
+
expires_at: raw.expires_at || new Date(Date.now() + 3600000).toISOString()
|
|
165
|
+
};
|
|
156
166
|
// fan-out to all subscribers
|
|
157
167
|
for (const q of channel.subscribers)
|
|
158
168
|
q.push(msg);
|
package/dist/utils/events.d.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
export type EventHandler<T = unknown> = (event: T) => void;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Event emitter that supports both typed and untyped usage.
|
|
4
|
+
*
|
|
5
|
+
* - Use without type parameter for untyped events (backward compatible)
|
|
6
|
+
* - Use with EventMap type parameter for type-safe events
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Untyped usage
|
|
10
|
+
* const emitter = new SimpleEventEmitter();
|
|
11
|
+
* emitter.on('foo', (data) => console.log(data));
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Typed usage
|
|
15
|
+
* type Events = { foo: string; bar: number };
|
|
16
|
+
* const emitter = new SimpleEventEmitter<Events>();
|
|
17
|
+
* emitter.on('foo', (data) => console.log(data)); // data is string
|
|
18
|
+
*/
|
|
19
|
+
export declare class SimpleEventEmitter<EventMap extends Record<string, any> = Record<string, unknown>> {
|
|
3
20
|
private listeners;
|
|
4
|
-
on(event:
|
|
5
|
-
emit(event:
|
|
21
|
+
on<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): () => void;
|
|
22
|
+
emit<K extends keyof EventMap>(event: K, payload: EventMap[K]): void;
|
|
6
23
|
clear(): void;
|
|
7
24
|
}
|
package/dist/utils/events.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event emitter that supports both typed and untyped usage.
|
|
3
|
+
*
|
|
4
|
+
* - Use without type parameter for untyped events (backward compatible)
|
|
5
|
+
* - Use with EventMap type parameter for type-safe events
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Untyped usage
|
|
9
|
+
* const emitter = new SimpleEventEmitter();
|
|
10
|
+
* emitter.on('foo', (data) => console.log(data));
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Typed usage
|
|
14
|
+
* type Events = { foo: string; bar: number };
|
|
15
|
+
* const emitter = new SimpleEventEmitter<Events>();
|
|
16
|
+
* emitter.on('foo', (data) => console.log(data)); // data is string
|
|
17
|
+
*/
|
|
1
18
|
export class SimpleEventEmitter {
|
|
2
19
|
listeners = new Map();
|
|
3
20
|
on(event, handler) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WebhookVerificationOptions } from './types.js';
|
|
2
|
+
import type { EventType, WebhookMessage } from '../events/types.js';
|
|
2
3
|
export declare class WebhookClient {
|
|
3
4
|
constructor();
|
|
4
5
|
/**
|
|
@@ -10,5 +11,5 @@ export declare class WebhookClient {
|
|
|
10
11
|
* @param options - Optional overrides controlling signature verification behavior.
|
|
11
12
|
* @returns Verified webhook payload when the signature matches.
|
|
12
13
|
*/
|
|
13
|
-
verifySignature<E extends
|
|
14
|
+
verifySignature<E extends EventType = EventType>(receivedData: any, receivedSignature: string, secretKey: string, options?: WebhookVerificationOptions): WebhookMessage<E>;
|
|
14
15
|
}
|
package/dist/webhook/types.d.ts
CHANGED
|
@@ -5,111 +5,3 @@ export declare class VerificationError extends Error {
|
|
|
5
5
|
export interface WebhookVerificationOptions {
|
|
6
6
|
allowExpired?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare enum WebhookEventType {
|
|
9
|
-
ExecutionQueued = "execution.queued",
|
|
10
|
-
ExecutionStart = "execution.start",
|
|
11
|
-
ExecutionStep = "execution.step",
|
|
12
|
-
InteractionWaiting = "interaction.waiting",
|
|
13
|
-
InteractionFinished = "interaction.finished",
|
|
14
|
-
AgentErrorAnalysis = "agent.error_analysis",
|
|
15
|
-
ExecutionRequeued = "execution.requeued",
|
|
16
|
-
ExecutionSuccess = "execution.success",
|
|
17
|
-
ExecutionFailed = "execution.failed",
|
|
18
|
-
ExecutionStopped = "execution.stopped"
|
|
19
|
-
}
|
|
20
|
-
export interface ExecutionQueuedPayload {
|
|
21
|
-
session_id: string;
|
|
22
|
-
workflow_id: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ExecutionStartPayload {
|
|
25
|
-
session_id: string;
|
|
26
|
-
workflow_id: string;
|
|
27
|
-
live_view_url?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface ExecutionStepPayload {
|
|
30
|
-
session_id: string;
|
|
31
|
-
workflow_id: string;
|
|
32
|
-
current_step: string;
|
|
33
|
-
next_step: string;
|
|
34
|
-
}
|
|
35
|
-
export interface InteractionWaitingPayload {
|
|
36
|
-
session_id: string;
|
|
37
|
-
workflow_id: string;
|
|
38
|
-
current_step: string;
|
|
39
|
-
missing_properties: string[];
|
|
40
|
-
expected_json_schema_datamodel: Record<string, any>;
|
|
41
|
-
message: string;
|
|
42
|
-
}
|
|
43
|
-
export type InteractionFinishedPayload = {
|
|
44
|
-
session_id: string;
|
|
45
|
-
workflow_id: string;
|
|
46
|
-
current_step: string;
|
|
47
|
-
missing_properties: [];
|
|
48
|
-
expected_json_schema_datamodel: Record<string, any>;
|
|
49
|
-
message: string;
|
|
50
|
-
} | {
|
|
51
|
-
session_id: string;
|
|
52
|
-
workflow_id: string;
|
|
53
|
-
provided_input: any;
|
|
54
|
-
message?: string;
|
|
55
|
-
expected_json_schema_datamodel: Record<string, any>;
|
|
56
|
-
};
|
|
57
|
-
export interface AgentErrorAnalysisPayload {
|
|
58
|
-
analysis_step_name: string;
|
|
59
|
-
ai_analysis?: string;
|
|
60
|
-
root_cause_analysis?: string;
|
|
61
|
-
error_category?: string;
|
|
62
|
-
}
|
|
63
|
-
export interface ExecutionRequeuedPayload {
|
|
64
|
-
session_id: string;
|
|
65
|
-
workflow_id: string;
|
|
66
|
-
retry_attempt: number;
|
|
67
|
-
max_retries?: number;
|
|
68
|
-
next_execution_time: string;
|
|
69
|
-
delay_ms: number;
|
|
70
|
-
}
|
|
71
|
-
export interface EndRunError {
|
|
72
|
-
message: string;
|
|
73
|
-
error_id: string;
|
|
74
|
-
full_url?: string;
|
|
75
|
-
created_at: string;
|
|
76
|
-
error_code?: string;
|
|
77
|
-
action_type?: string;
|
|
78
|
-
action_display_name?: string;
|
|
79
|
-
llm_error_category?: string;
|
|
80
|
-
}
|
|
81
|
-
export interface EndRunPayload {
|
|
82
|
-
session_id: string;
|
|
83
|
-
workflow_id: string;
|
|
84
|
-
data: any;
|
|
85
|
-
input_variables: Record<string, any>;
|
|
86
|
-
errors: EndRunError[];
|
|
87
|
-
status: "execution.success" | "execution.failed" | "execution.stopped";
|
|
88
|
-
encrypted_variables: string[] | null;
|
|
89
|
-
file_urls: any[] | null;
|
|
90
|
-
}
|
|
91
|
-
export interface ExecutionStoppedEarlyPayload {
|
|
92
|
-
message: string;
|
|
93
|
-
error_code: string;
|
|
94
|
-
session_id: string;
|
|
95
|
-
}
|
|
96
|
-
export interface WebhookEnvelope<E extends WebhookEventType, P> {
|
|
97
|
-
event: E;
|
|
98
|
-
timestamp: number;
|
|
99
|
-
expires_at: number;
|
|
100
|
-
payload: P;
|
|
101
|
-
metadata?: Record<string, any>;
|
|
102
|
-
}
|
|
103
|
-
export type WebhookPayloadMap = {
|
|
104
|
-
[WebhookEventType.ExecutionQueued]: ExecutionQueuedPayload;
|
|
105
|
-
[WebhookEventType.ExecutionStart]: ExecutionStartPayload;
|
|
106
|
-
[WebhookEventType.ExecutionStep]: ExecutionStepPayload;
|
|
107
|
-
[WebhookEventType.InteractionWaiting]: InteractionWaitingPayload;
|
|
108
|
-
[WebhookEventType.InteractionFinished]: InteractionFinishedPayload;
|
|
109
|
-
[WebhookEventType.AgentErrorAnalysis]: AgentErrorAnalysisPayload;
|
|
110
|
-
[WebhookEventType.ExecutionRequeued]: ExecutionRequeuedPayload;
|
|
111
|
-
[WebhookEventType.ExecutionSuccess]: EndRunPayload;
|
|
112
|
-
[WebhookEventType.ExecutionFailed]: EndRunPayload;
|
|
113
|
-
[WebhookEventType.ExecutionStopped]: EndRunPayload | ExecutionStoppedEarlyPayload;
|
|
114
|
-
};
|
|
115
|
-
export type WebhookPayload<E extends WebhookEventType = WebhookEventType> = E extends WebhookEventType ? WebhookEnvelope<E, WebhookPayloadMap[E]> : never;
|
package/dist/webhook/types.js
CHANGED
|
@@ -6,16 +6,3 @@ export class VerificationError extends Error {
|
|
|
6
6
|
this.name = "VerificationError";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
export var WebhookEventType;
|
|
10
|
-
(function (WebhookEventType) {
|
|
11
|
-
WebhookEventType["ExecutionQueued"] = "execution.queued";
|
|
12
|
-
WebhookEventType["ExecutionStart"] = "execution.start";
|
|
13
|
-
WebhookEventType["ExecutionStep"] = "execution.step";
|
|
14
|
-
WebhookEventType["InteractionWaiting"] = "interaction.waiting";
|
|
15
|
-
WebhookEventType["InteractionFinished"] = "interaction.finished";
|
|
16
|
-
WebhookEventType["AgentErrorAnalysis"] = "agent.error_analysis";
|
|
17
|
-
WebhookEventType["ExecutionRequeued"] = "execution.requeued";
|
|
18
|
-
WebhookEventType["ExecutionSuccess"] = "execution.success";
|
|
19
|
-
WebhookEventType["ExecutionFailed"] = "execution.failed";
|
|
20
|
-
WebhookEventType["ExecutionStopped"] = "execution.stopped";
|
|
21
|
-
})(WebhookEventType || (WebhookEventType = {}));
|
package/dist/webhook/utils.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { EventType, WebhookMessage } from '../events/types.js';
|
|
2
|
+
import { type WebhookVerificationOptions } from './types.js';
|
|
3
|
+
export declare function verifyMessage<E extends EventType = EventType>(receivedData: any, receivedSignature: string, secretKey: string, options?: WebhookVerificationOptions): WebhookMessage<E>;
|