cloudcruise 0.0.4 → 0.0.6

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.
@@ -4,6 +4,10 @@ import { RunsClient } from './runs/RunsClient.js';
4
4
  import { WebhookClient } from './webhook/WebhookClient.js';
5
5
  export interface CloudCruiseParams {
6
6
  apiKey?: string;
7
+ /**
8
+ * CloudCruise API base URL. Authenticated requests are restricted to the
9
+ * production CloudCruise API origin.
10
+ */
7
11
  baseUrl?: string;
8
12
  encryptionKey?: string;
9
13
  }
@@ -4,6 +4,34 @@ import { WorkflowsClient } from './workflows/WorkflowsClient.js';
4
4
  import { RunsClient } from './runs/RunsClient.js';
5
5
  import { WebhookClient } from './webhook/WebhookClient.js';
6
6
  import { ConnectionManager } from './utils/connectionManager.js';
7
+ const DEFAULT_BASE_URL = 'https://api.cloudcruise.com';
8
+ const DEFAULT_API_HOST = new URL(DEFAULT_BASE_URL).host.toLowerCase();
9
+ function normalizeBaseUrl(baseUrl) {
10
+ let url;
11
+ try {
12
+ url = new URL(baseUrl);
13
+ }
14
+ catch {
15
+ throw new Error(`Invalid baseUrl: ${baseUrl}`);
16
+ }
17
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
18
+ throw new Error(`Invalid baseUrl protocol: ${url.protocol}. Use https: or http:.`);
19
+ }
20
+ url.search = '';
21
+ url.hash = '';
22
+ return url.toString().replace(/\/+$/, '');
23
+ }
24
+ function assertBaseUrlAllowed(baseUrl) {
25
+ const url = new URL(baseUrl);
26
+ const host = url.host.toLowerCase();
27
+ if (host === DEFAULT_API_HOST && url.protocol !== 'https:') {
28
+ throw new Error(`Refusing to send CloudCruise API key to "${baseUrl}". The default CloudCruise API host requires https:.`);
29
+ }
30
+ if (baseUrl !== DEFAULT_BASE_URL) {
31
+ throw new Error(`Refusing to send CloudCruise API key to unapproved baseUrl "${baseUrl}". ` +
32
+ `Authenticated requests are restricted to ${DEFAULT_BASE_URL}.`);
33
+ }
34
+ }
7
35
  export class CloudCruise {
8
36
  apiKey;
9
37
  baseUrl;
@@ -15,7 +43,7 @@ export class CloudCruise {
15
43
  connectionManager;
16
44
  constructor(params) {
17
45
  const apiKey = params?.apiKey ?? getEnv('CLOUDCRUISE_API_KEY');
18
- const baseUrl = params?.baseUrl ?? getEnv('CLOUDCRUISE_BASE_URL') ?? 'https://api.cloudcruise.com';
46
+ const baseUrl = params?.baseUrl ?? getEnv('CLOUDCRUISE_BASE_URL') ?? DEFAULT_BASE_URL;
19
47
  const encryptionKey = params?.encryptionKey ?? getEnv('CLOUDCRUISE_ENCRYPTION_KEY');
20
48
  if (!apiKey) {
21
49
  throw new Error('Missing apiKey. Provide via params.apiKey or CLOUDCRUISE_API_KEY env var.');
@@ -23,8 +51,10 @@ export class CloudCruise {
23
51
  if (!encryptionKey) {
24
52
  throw new Error('Missing encryptionKey. Provide via params.encryptionKey or CLOUDCRUISE_ENCRYPTION_KEY env var.');
25
53
  }
54
+ const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
55
+ assertBaseUrlAllowed(normalizedBaseUrl);
26
56
  this.apiKey = apiKey;
27
- this.baseUrl = baseUrl.replace(/\/$/, ''); // Remove trailing slash
57
+ this.baseUrl = normalizedBaseUrl;
28
58
  this.encryptionKey = encryptionKey;
29
59
  // Initialize namespace clients
30
60
  this.connectionManager = new ConnectionManager(this.baseUrl, this.apiKey);
@@ -89,6 +89,7 @@ export interface EndRunPayload {
89
89
  status: EventType.ExecutionSuccess | EventType.ExecutionFailed | EventType.ExecutionStopped;
90
90
  encrypted_variables: string[] | null;
91
91
  file_urls: any[] | null;
92
+ vault_entries: Record<string, any> | null;
92
93
  }
93
94
  export interface ExecutionStoppedEarlyPayload {
94
95
  message: string;
@@ -71,6 +71,8 @@ export interface WorkflowError {
71
71
  error_code?: string | null;
72
72
  action_type?: string | null;
73
73
  action_display_name?: string | null;
74
+ llm_error_category?: string | null;
75
+ original_error?: string | null;
74
76
  }
75
77
  export interface RunResult {
76
78
  session_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcruise",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "The official CloudCruise JS/TS client.",
5
5
  "homepage": "https://github.com/CloudCruise/cloudcruise-js#readme",
6
6
  "bugs": {
@@ -18,16 +18,16 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "scripts": {
22
- "build": "tsc",
23
- "dev": "tsc --watch",
24
- "test": "pnpm build && node --test test/*.test.js"
25
- },
26
21
  "devDependencies": {
27
22
  "@types/node": "^20.0.0",
28
23
  "typescript": "^5.0.0"
29
24
  },
30
25
  "engines": {
31
26
  "node": ">=18.0.0"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "test": "pnpm build && node --test test/*.test.js"
32
32
  }
33
- }
33
+ }