cloudcruise 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CloudCruise.d.ts +29 -0
- package/dist/CloudCruise.js +113 -0
- package/dist/events/types.d.ts +186 -0
- package/dist/events/types.js +23 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +13 -0
- package/dist/runs/RunsClient.d.ts +101 -0
- package/dist/runs/RunsClient.js +400 -0
- package/dist/runs/types.d.ts +157 -0
- package/dist/runs/types.js +4 -0
- package/dist/utils/asyncQueue.d.ts +9 -0
- package/dist/utils/asyncQueue.js +43 -0
- package/dist/utils/connectionManager.d.ts +29 -0
- package/dist/utils/connectionManager.js +234 -0
- package/dist/utils/env.d.ts +2 -0
- package/dist/utils/env.js +9 -0
- package/dist/utils/events.d.ts +24 -0
- package/dist/utils/events.js +40 -0
- package/dist/utils/sse.d.ts +24 -0
- package/dist/utils/sse.js +122 -0
- package/dist/vault/VaultClient.d.ts +55 -0
- package/dist/vault/VaultClient.js +115 -0
- package/dist/vault/types.d.ts +62 -0
- package/dist/vault/types.js +4 -0
- package/dist/vault/utils.d.ts +34 -0
- package/dist/vault/utils.js +122 -0
- package/dist/webhook/WebhookClient.d.ts +15 -0
- package/dist/webhook/WebhookClient.js +18 -0
- package/dist/webhook/types.d.ts +7 -0
- package/dist/webhook/types.js +8 -0
- package/dist/webhook/utils.d.ts +3 -0
- package/dist/webhook/utils.js +49 -0
- package/dist/workflows/WorkflowsClient.d.ts +19 -0
- package/dist/workflows/WorkflowsClient.js +97 -0
- package/dist/workflows/types.d.ts +41 -0
- package/dist/workflows/types.js +15 -0
- package/package.json +2 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { VaultClient } from './vault/VaultClient.js';
|
|
2
|
+
import { WorkflowsClient } from './workflows/WorkflowsClient.js';
|
|
3
|
+
import { RunsClient } from './runs/RunsClient.js';
|
|
4
|
+
import { WebhookClient } from './webhook/WebhookClient.js';
|
|
5
|
+
export interface CloudCruiseParams {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/**
|
|
8
|
+
* CloudCruise API base URL. Authenticated requests are restricted to the
|
|
9
|
+
* production CloudCruise API origin or the staging API origin.
|
|
10
|
+
*/
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
encryptionKey?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class CloudCruise {
|
|
15
|
+
private readonly apiKey;
|
|
16
|
+
private readonly baseUrl;
|
|
17
|
+
private readonly encryptionKey;
|
|
18
|
+
readonly vault: VaultClient;
|
|
19
|
+
readonly workflows: WorkflowsClient;
|
|
20
|
+
readonly runs: RunsClient;
|
|
21
|
+
readonly webhook: WebhookClient;
|
|
22
|
+
private readonly connectionManager;
|
|
23
|
+
constructor(params?: CloudCruiseParams);
|
|
24
|
+
/**
|
|
25
|
+
* Makes an HTTP request to the CloudCruise API
|
|
26
|
+
* Automatically adds the cc-key header for authentication
|
|
27
|
+
*/
|
|
28
|
+
private makeRequest;
|
|
29
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { getEnv } from './utils/env.js';
|
|
2
|
+
import { VaultClient } from './vault/VaultClient.js';
|
|
3
|
+
import { WorkflowsClient } from './workflows/WorkflowsClient.js';
|
|
4
|
+
import { RunsClient } from './runs/RunsClient.js';
|
|
5
|
+
import { WebhookClient } from './webhook/WebhookClient.js';
|
|
6
|
+
import { ConnectionManager } from './utils/connectionManager.js';
|
|
7
|
+
const DEFAULT_BASE_URL = 'https://api.cloudcruise.com';
|
|
8
|
+
const STAGING_BASE_URL = 'https://staging-api.cloudcruise.app';
|
|
9
|
+
const ALLOWED_BASE_URLS = new Set([DEFAULT_BASE_URL, STAGING_BASE_URL]);
|
|
10
|
+
const DEFAULT_API_HOST = new URL(DEFAULT_BASE_URL).host.toLowerCase();
|
|
11
|
+
function normalizeBaseUrl(baseUrl) {
|
|
12
|
+
let url;
|
|
13
|
+
try {
|
|
14
|
+
url = new URL(baseUrl);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw new Error(`Invalid baseUrl: ${baseUrl}`);
|
|
18
|
+
}
|
|
19
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
20
|
+
throw new Error(`Invalid baseUrl protocol: ${url.protocol}. Use https: or http:.`);
|
|
21
|
+
}
|
|
22
|
+
url.search = '';
|
|
23
|
+
url.hash = '';
|
|
24
|
+
return url.toString().replace(/\/+$/, '');
|
|
25
|
+
}
|
|
26
|
+
function assertBaseUrlAllowed(baseUrl) {
|
|
27
|
+
const url = new URL(baseUrl);
|
|
28
|
+
const host = url.host.toLowerCase();
|
|
29
|
+
if (host === DEFAULT_API_HOST && url.protocol !== 'https:') {
|
|
30
|
+
throw new Error(`Refusing to send CloudCruise API key to "${baseUrl}". The default CloudCruise API host requires https:.`);
|
|
31
|
+
}
|
|
32
|
+
if (!ALLOWED_BASE_URLS.has(baseUrl)) {
|
|
33
|
+
throw new Error(`Refusing to send CloudCruise API key to unapproved baseUrl "${baseUrl}". ` +
|
|
34
|
+
`Authenticated requests are restricted to: ${Array.from(ALLOWED_BASE_URLS).join(", ")}.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class CloudCruise {
|
|
38
|
+
apiKey;
|
|
39
|
+
baseUrl;
|
|
40
|
+
encryptionKey;
|
|
41
|
+
vault;
|
|
42
|
+
workflows;
|
|
43
|
+
runs;
|
|
44
|
+
webhook;
|
|
45
|
+
connectionManager;
|
|
46
|
+
constructor(params) {
|
|
47
|
+
const apiKey = params?.apiKey ?? getEnv('CLOUDCRUISE_API_KEY');
|
|
48
|
+
const baseUrl = params?.baseUrl ?? getEnv('CLOUDCRUISE_BASE_URL') ?? DEFAULT_BASE_URL;
|
|
49
|
+
const encryptionKey = params?.encryptionKey ?? getEnv('CLOUDCRUISE_ENCRYPTION_KEY');
|
|
50
|
+
if (!apiKey) {
|
|
51
|
+
throw new Error('Missing apiKey. Provide via params.apiKey or CLOUDCRUISE_API_KEY env var.');
|
|
52
|
+
}
|
|
53
|
+
if (!encryptionKey) {
|
|
54
|
+
throw new Error('Missing encryptionKey. Provide via params.encryptionKey or CLOUDCRUISE_ENCRYPTION_KEY env var.');
|
|
55
|
+
}
|
|
56
|
+
const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
57
|
+
assertBaseUrlAllowed(normalizedBaseUrl);
|
|
58
|
+
this.apiKey = apiKey;
|
|
59
|
+
this.baseUrl = normalizedBaseUrl;
|
|
60
|
+
this.encryptionKey = encryptionKey;
|
|
61
|
+
// Initialize namespace clients
|
|
62
|
+
this.connectionManager = new ConnectionManager(this.baseUrl, this.apiKey);
|
|
63
|
+
this.vault = new VaultClient(this.makeRequest.bind(this), this.encryptionKey);
|
|
64
|
+
this.workflows = new WorkflowsClient(this.makeRequest.bind(this));
|
|
65
|
+
this.runs = new RunsClient(this.connectionManager, this.makeRequest.bind(this), this.workflows);
|
|
66
|
+
this.webhook = new WebhookClient();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Makes an HTTP request to the CloudCruise API
|
|
70
|
+
* Automatically adds the cc-key header for authentication
|
|
71
|
+
*/
|
|
72
|
+
async makeRequest(method, path, body) {
|
|
73
|
+
const url = `${this.baseUrl}${path}`;
|
|
74
|
+
const headers = {
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
'cc-key': this.apiKey
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetch(url, {
|
|
80
|
+
method,
|
|
81
|
+
headers,
|
|
82
|
+
body: body ? JSON.stringify(body) : undefined
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
const errorText = await response.text();
|
|
86
|
+
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
87
|
+
try {
|
|
88
|
+
const errorJson = JSON.parse(errorText);
|
|
89
|
+
errorMessage = errorJson.message || errorJson.error || errorMessage;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Use HTTP status if we can't parse error response
|
|
93
|
+
}
|
|
94
|
+
throw new Error(errorMessage);
|
|
95
|
+
}
|
|
96
|
+
const contentType = response.headers.get('content-type');
|
|
97
|
+
if (contentType && contentType.includes('application/json')) {
|
|
98
|
+
return await response.json();
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return await response.text();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error instanceof Error) {
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw new Error(`Request failed: ${String(error)}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
ExecutionInputRequired = "execution.input_required"
|
|
22
|
+
}
|
|
23
|
+
export interface ExecutionQueuedPayload {
|
|
24
|
+
session_id: string;
|
|
25
|
+
workflow_id: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ExecutionStartPayload {
|
|
28
|
+
session_id: string;
|
|
29
|
+
workflow_id: string;
|
|
30
|
+
live_view_url?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ExecutionStepPayload {
|
|
33
|
+
session_id: string;
|
|
34
|
+
workflow_id: string;
|
|
35
|
+
current_step: string;
|
|
36
|
+
next_step: string;
|
|
37
|
+
}
|
|
38
|
+
export interface InteractionWaitingPayload {
|
|
39
|
+
session_id: string;
|
|
40
|
+
workflow_id: string;
|
|
41
|
+
current_step: string;
|
|
42
|
+
missing_properties: string[];
|
|
43
|
+
expected_json_schema_datamodel: Record<string, any>;
|
|
44
|
+
message: string;
|
|
45
|
+
}
|
|
46
|
+
export type InteractionFinishedPayload = {
|
|
47
|
+
session_id: string;
|
|
48
|
+
workflow_id: string;
|
|
49
|
+
current_step: string;
|
|
50
|
+
missing_properties: [];
|
|
51
|
+
expected_json_schema_datamodel: Record<string, any>;
|
|
52
|
+
message: string;
|
|
53
|
+
} | {
|
|
54
|
+
session_id: string;
|
|
55
|
+
workflow_id: string;
|
|
56
|
+
provided_input: any;
|
|
57
|
+
message?: string;
|
|
58
|
+
expected_json_schema_datamodel: Record<string, any>;
|
|
59
|
+
};
|
|
60
|
+
export interface AgentErrorAnalysisPayload {
|
|
61
|
+
analysis_step_name: string;
|
|
62
|
+
ai_analysis?: string;
|
|
63
|
+
root_cause_analysis?: string;
|
|
64
|
+
error_category?: string;
|
|
65
|
+
phase?: "modal_decision_dispatched" | "popup_dismiss_verified" | string;
|
|
66
|
+
session_id?: string;
|
|
67
|
+
modal_action?: string;
|
|
68
|
+
modal_action_label?: string;
|
|
69
|
+
response_time_ms?: number;
|
|
70
|
+
outcome?: "success" | "failure";
|
|
71
|
+
host?: string;
|
|
72
|
+
popup_signature?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface AvailableAction {
|
|
75
|
+
id: string;
|
|
76
|
+
label: string;
|
|
77
|
+
}
|
|
78
|
+
export interface PopupRetry {
|
|
79
|
+
attempt: number;
|
|
80
|
+
max_attempts: number;
|
|
81
|
+
}
|
|
82
|
+
export interface PopupContext {
|
|
83
|
+
error_description: string;
|
|
84
|
+
error_sub_type?: string;
|
|
85
|
+
full_url?: string;
|
|
86
|
+
available_actions: AvailableAction[];
|
|
87
|
+
retry: PopupRetry;
|
|
88
|
+
}
|
|
89
|
+
export type InputRequiredReason = "input_required" | "incorrect_form_input" | "multiple_matching_results" | "non_dismissible_popup";
|
|
90
|
+
export interface ExecutionInputRequiredPayload {
|
|
91
|
+
session_id: string;
|
|
92
|
+
input_variables: Record<string, any>;
|
|
93
|
+
screenshot_url: string | null;
|
|
94
|
+
reason?: InputRequiredReason;
|
|
95
|
+
popup_context?: PopupContext;
|
|
96
|
+
}
|
|
97
|
+
export interface ExecutionRequeuedPayload {
|
|
98
|
+
session_id: string;
|
|
99
|
+
workflow_id: string;
|
|
100
|
+
retry_attempt: number;
|
|
101
|
+
max_retries?: number;
|
|
102
|
+
next_execution_time: string;
|
|
103
|
+
delay_ms: number;
|
|
104
|
+
}
|
|
105
|
+
export interface EndRunError {
|
|
106
|
+
message: string;
|
|
107
|
+
error_id: string;
|
|
108
|
+
full_url?: string;
|
|
109
|
+
created_at: string;
|
|
110
|
+
error_code?: string;
|
|
111
|
+
action_type?: string;
|
|
112
|
+
action_display_name?: string;
|
|
113
|
+
llm_error_category?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface EndRunPayload {
|
|
116
|
+
session_id: string;
|
|
117
|
+
workflow_id: string;
|
|
118
|
+
data: any;
|
|
119
|
+
input_variables: Record<string, any>;
|
|
120
|
+
errors: EndRunError[];
|
|
121
|
+
status: EventType.ExecutionSuccess | EventType.ExecutionFailed | EventType.ExecutionStopped;
|
|
122
|
+
encrypted_variables: string[] | null;
|
|
123
|
+
file_urls: any[] | null;
|
|
124
|
+
vault_entries: Record<string, any> | null;
|
|
125
|
+
}
|
|
126
|
+
export interface ExecutionStoppedEarlyPayload {
|
|
127
|
+
message: string;
|
|
128
|
+
error_code: string;
|
|
129
|
+
session_id: string;
|
|
130
|
+
}
|
|
131
|
+
export interface FileUploadedPayload {
|
|
132
|
+
signed_file_url: string;
|
|
133
|
+
file_name: string;
|
|
134
|
+
timestamp: string;
|
|
135
|
+
signed_file_url_expires: string;
|
|
136
|
+
metadata: Record<string, any>;
|
|
137
|
+
session_id: string;
|
|
138
|
+
}
|
|
139
|
+
export interface ScreenshotUploadedPayload {
|
|
140
|
+
screenshot_id: string;
|
|
141
|
+
signed_screenshot_url: string;
|
|
142
|
+
node_display_name: string;
|
|
143
|
+
node_id: string;
|
|
144
|
+
timestamp: string;
|
|
145
|
+
signed_screenshot_url_expires: string;
|
|
146
|
+
error_screenshot: boolean;
|
|
147
|
+
retry_index: number;
|
|
148
|
+
full_length_screenshot: boolean;
|
|
149
|
+
session_id: string;
|
|
150
|
+
}
|
|
151
|
+
export type EventPayloadMap = {
|
|
152
|
+
[EventType.ExecutionQueued]: ExecutionQueuedPayload;
|
|
153
|
+
[EventType.ExecutionStart]: ExecutionStartPayload;
|
|
154
|
+
[EventType.ExecutionStep]: ExecutionStepPayload;
|
|
155
|
+
[EventType.InteractionWaiting]: InteractionWaitingPayload;
|
|
156
|
+
[EventType.InteractionFinished]: InteractionFinishedPayload;
|
|
157
|
+
[EventType.AgentErrorAnalysis]: AgentErrorAnalysisPayload;
|
|
158
|
+
[EventType.ExecutionRequeued]: ExecutionRequeuedPayload;
|
|
159
|
+
[EventType.ExecutionSuccess]: EndRunPayload;
|
|
160
|
+
[EventType.ExecutionFailed]: EndRunPayload;
|
|
161
|
+
[EventType.ExecutionStopped]: EndRunPayload | ExecutionStoppedEarlyPayload;
|
|
162
|
+
[EventType.FileUploaded]: FileUploadedPayload;
|
|
163
|
+
[EventType.ScreenshotUploaded]: ScreenshotUploadedPayload;
|
|
164
|
+
[EventType.VideoUploaded]: never;
|
|
165
|
+
[EventType.ExecutionPause]: never;
|
|
166
|
+
[EventType.InteractionFailed]: never;
|
|
167
|
+
[EventType.ExecutionInputRequired]: ExecutionInputRequiredPayload;
|
|
168
|
+
};
|
|
169
|
+
export type WebhookMessage<E extends EventType = EventType> = {
|
|
170
|
+
event: E;
|
|
171
|
+
timestamp: number;
|
|
172
|
+
expires_at: number;
|
|
173
|
+
payload: EventPayloadMap[E];
|
|
174
|
+
metadata?: Record<string, any>;
|
|
175
|
+
};
|
|
176
|
+
export type RunEventMessage<E extends EventType = EventType> = {
|
|
177
|
+
event: "run.event";
|
|
178
|
+
data: {
|
|
179
|
+
event: E;
|
|
180
|
+
payload: EventPayloadMap[E];
|
|
181
|
+
timestamp: number;
|
|
182
|
+
expires_at: number;
|
|
183
|
+
};
|
|
184
|
+
timestamp: string;
|
|
185
|
+
expires_at: string;
|
|
186
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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["ExecutionInputRequired"] = "execution.input_required";
|
|
23
|
+
})(EventType || (EventType = {}));
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudCruise JavaScript/TypeScript SDK
|
|
3
|
+
* Official client library for the CloudCruise Platform
|
|
4
|
+
*/
|
|
5
|
+
export { CloudCruise } from './CloudCruise.js';
|
|
6
|
+
export type { CloudCruiseParams } from './CloudCruise.js';
|
|
7
|
+
export { VaultClient } from './vault/VaultClient.js';
|
|
8
|
+
export { WorkflowsClient } from './workflows/WorkflowsClient.js';
|
|
9
|
+
export { RunsClient } from './runs/RunsClient.js';
|
|
10
|
+
export { WebhookClient } from './webhook/WebhookClient.js';
|
|
11
|
+
export type { VaultEntry, GetVaultEntriesFilters, ProxyConfig, VaultPostPutHeadersInBody } from './vault/types.js';
|
|
12
|
+
export type { Workflow, WorkflowInputSchema, WorkflowMetadata } from './workflows/types.js';
|
|
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, AvailableAction, PopupRetry, PopupContext, InputRequiredReason, ExecutionInputRequiredPayload, AgentErrorAnalysisPayload } from './events/types.js';
|
|
16
|
+
export type { WebhookVerificationOptions } from './webhook/types.js';
|
|
17
|
+
export { VerificationError } from './webhook/types.js';
|
|
18
|
+
export { InputValidationError } from './workflows/types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudCruise JavaScript/TypeScript SDK
|
|
3
|
+
* Official client library for the CloudCruise Platform
|
|
4
|
+
*/
|
|
5
|
+
export { CloudCruise } from './CloudCruise.js';
|
|
6
|
+
export { VaultClient } from './vault/VaultClient.js';
|
|
7
|
+
export { WorkflowsClient } from './workflows/WorkflowsClient.js';
|
|
8
|
+
export { RunsClient } from './runs/RunsClient.js';
|
|
9
|
+
export { WebhookClient } from './webhook/WebhookClient.js';
|
|
10
|
+
// Export shared event types
|
|
11
|
+
export { EventType } from './events/types.js';
|
|
12
|
+
export { VerificationError } from './webhook/types.js';
|
|
13
|
+
export { InputValidationError } from './workflows/types.js';
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { StartRunRequest, UserInteractionData, GetRunResult, WebhookReplayResponse, RunHandle, RunStreamOptions } from './types.js';
|
|
2
|
+
import type { PopupContext, ExecutionInputRequiredPayload } from '../events/types.js';
|
|
3
|
+
import { ConnectionManager } from '../utils/connectionManager.js';
|
|
4
|
+
export declare class RunsClient {
|
|
5
|
+
private readonly makeRequest;
|
|
6
|
+
private readonly workflows?;
|
|
7
|
+
private readonly connectionManager;
|
|
8
|
+
constructor(connectionManager: ConnectionManager, makeRequest: <T = any>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, body?: any) => Promise<T>, workflows?: {
|
|
9
|
+
validateWorkflowInput: (workflowId: string, payload: Record<string, any>) => Promise<void>;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Queues a new run and returns a RunHandle.
|
|
13
|
+
* The handle exposes sessionId immediately and subscribes to SSE under the hood.
|
|
14
|
+
*/
|
|
15
|
+
start(request: StartRunRequest, options?: RunStreamOptions): Promise<RunHandle>;
|
|
16
|
+
/**
|
|
17
|
+
* Subscribes to SSE events for a given session. Returns a handle with helpers.
|
|
18
|
+
*/
|
|
19
|
+
subscribeToSession(sessionId: string, options?: RunStreamOptions): RunHandle;
|
|
20
|
+
/**
|
|
21
|
+
* Submits user interaction data during an active run
|
|
22
|
+
* @param sessionId - The unique identifier for the workflow execution session
|
|
23
|
+
* @param data - User input data as key-value pairs
|
|
24
|
+
*/
|
|
25
|
+
submitUserInteraction(sessionId: string, data: UserInteractionData): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Responds to an execution.input_required event whose reason is
|
|
28
|
+
* "non_dismissible_popup" by picking one of the CTA buttons surfaced in
|
|
29
|
+
* popup_context.available_actions. The backend dispatches a synthetic
|
|
30
|
+
* click on the chosen button and resumes the workflow.
|
|
31
|
+
*
|
|
32
|
+
* Only valid while the session is waiting for input. The backing endpoint
|
|
33
|
+
* returns 400 if the wait already expired (the workspace setting
|
|
34
|
+
* input_required_timeout_seconds, default 15s, max 300s).
|
|
35
|
+
*
|
|
36
|
+
* @param sessionId - The session waiting for input.
|
|
37
|
+
* @param actionId - One of the ids in popup_context.available_actions.
|
|
38
|
+
*/
|
|
39
|
+
submitModalAction(sessionId: string, actionId: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Responds to an execution.input_required event whose reason is
|
|
42
|
+
* "input_required", "incorrect_form_input", or "multiple_matching_results"
|
|
43
|
+
* by supplying the corrected/required input variables. Backend resumes from
|
|
44
|
+
* the appropriate recovery node with the new values substituted in.
|
|
45
|
+
*
|
|
46
|
+
* Mutually exclusive with submitModalAction at the endpoint level.
|
|
47
|
+
*
|
|
48
|
+
* @param sessionId - The session waiting for input.
|
|
49
|
+
* @param inputVariables - Mapping of variable name to new value.
|
|
50
|
+
*/
|
|
51
|
+
submitInputVariables(sessionId: string, inputVariables: Record<string, any>): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Registers a listener that auto-responds ONLY to non-dismissible modal
|
|
54
|
+
* input_required events (reason === "non_dismissible_popup"). The decider
|
|
55
|
+
* receives the popup_context and must return one of the action ids in
|
|
56
|
+
* popup_context.available_actions.
|
|
57
|
+
*
|
|
58
|
+
* The SDK never picks an action on its own. The customer's decider IS the
|
|
59
|
+
* decision point. If decider throws, the listener swallows it and skips
|
|
60
|
+
* submission; the backend's input wait will time out naturally.
|
|
61
|
+
*
|
|
62
|
+
* Other input_required reasons (incorrect_form_input, etc.) are ignored
|
|
63
|
+
* here and should be routed to onInputVariablesRequired.
|
|
64
|
+
*
|
|
65
|
+
* @returns An unsubscribe callable.
|
|
66
|
+
*/
|
|
67
|
+
onPopupDecisionRequired(handle: RunHandle, decider: (ctx: PopupContext) => string | Promise<string>, onError?: (err: unknown) => void, options?: {
|
|
68
|
+
verbose?: boolean;
|
|
69
|
+
}): () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Registers a listener that auto-responds ONLY to workflow-variable
|
|
72
|
+
* input_required events (reason in {"input_required",
|
|
73
|
+
* "incorrect_form_input", "multiple_matching_results"}). The decider
|
|
74
|
+
* receives the full payload and must return the input_variables dict.
|
|
75
|
+
*
|
|
76
|
+
* Counterpart to onPopupDecisionRequired. Modal events
|
|
77
|
+
* (reason === "non_dismissible_popup") are routed there and ignored here.
|
|
78
|
+
*
|
|
79
|
+
* @returns An unsubscribe callable.
|
|
80
|
+
*/
|
|
81
|
+
onInputVariablesRequired(handle: RunHandle, decider: (payload: ExecutionInputRequiredPayload) => Record<string, any> | Promise<Record<string, any>>, onError?: (err: unknown) => void, options?: {
|
|
82
|
+
verbose?: boolean;
|
|
83
|
+
}): () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves comprehensive results and execution details for a specific run
|
|
86
|
+
* @param sessionId - The unique identifier for the workflow execution session
|
|
87
|
+
* @returns Promise resolving to complete run results
|
|
88
|
+
*/
|
|
89
|
+
getResults(sessionId: string): Promise<GetRunResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Interrupts a running browser agent run
|
|
92
|
+
* @param sessionId - The unique identifier for the workflow execution session
|
|
93
|
+
*/
|
|
94
|
+
interrupt(sessionId: string): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Replays all webhooks that were sent during a session
|
|
97
|
+
* @param sessionId - The ID of the session to replay webhooks for
|
|
98
|
+
* @returns Promise resolving to webhook replay results
|
|
99
|
+
*/
|
|
100
|
+
replayWebhooks(sessionId: string): Promise<WebhookReplayResponse>;
|
|
101
|
+
}
|