cloudcruise 0.0.1__tar.gz
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.
- cloudcruise-0.0.1/LICENSE +21 -0
- cloudcruise-0.0.1/PKG-INFO +136 -0
- cloudcruise-0.0.1/README.md +106 -0
- cloudcruise-0.0.1/cloudcruise/__init__.py +114 -0
- cloudcruise-0.0.1/cloudcruise/_default.py +31 -0
- cloudcruise-0.0.1/cloudcruise/cloudcruise.py +96 -0
- cloudcruise-0.0.1/cloudcruise/events/__init__.py +43 -0
- cloudcruise-0.0.1/cloudcruise/events/types.py +151 -0
- cloudcruise-0.0.1/cloudcruise/py.typed +0 -0
- cloudcruise-0.0.1/cloudcruise/runs/__init__.py +64 -0
- cloudcruise-0.0.1/cloudcruise/runs/client.py +258 -0
- cloudcruise-0.0.1/cloudcruise/runs/types.py +241 -0
- cloudcruise-0.0.1/cloudcruise/utils/async_queue.py +44 -0
- cloudcruise-0.0.1/cloudcruise/utils/connection_manager.py +212 -0
- cloudcruise-0.0.1/cloudcruise/utils/env.py +16 -0
- cloudcruise-0.0.1/cloudcruise/utils/events.py +38 -0
- cloudcruise-0.0.1/cloudcruise/utils/sse.py +130 -0
- cloudcruise-0.0.1/cloudcruise/vault/__init__.py +42 -0
- cloudcruise-0.0.1/cloudcruise/vault/client.py +80 -0
- cloudcruise-0.0.1/cloudcruise/vault/types.py +53 -0
- cloudcruise-0.0.1/cloudcruise/vault/utils.py +81 -0
- cloudcruise-0.0.1/cloudcruise/webhook/__init__.py +13 -0
- cloudcruise-0.0.1/cloudcruise/webhook/client.py +21 -0
- cloudcruise-0.0.1/cloudcruise/webhook/types.py +37 -0
- cloudcruise-0.0.1/cloudcruise/webhook/utils.py +58 -0
- cloudcruise-0.0.1/cloudcruise/workflows/__init__.py +39 -0
- cloudcruise-0.0.1/cloudcruise/workflows/client.py +118 -0
- cloudcruise-0.0.1/cloudcruise/workflows/types.py +58 -0
- cloudcruise-0.0.1/cloudcruise.egg-info/PKG-INFO +136 -0
- cloudcruise-0.0.1/cloudcruise.egg-info/SOURCES.txt +37 -0
- cloudcruise-0.0.1/cloudcruise.egg-info/dependency_links.txt +1 -0
- cloudcruise-0.0.1/cloudcruise.egg-info/requires.txt +9 -0
- cloudcruise-0.0.1/cloudcruise.egg-info/top_level.txt +1 -0
- cloudcruise-0.0.1/pyproject.toml +46 -0
- cloudcruise-0.0.1/setup.cfg +4 -0
- cloudcruise-0.0.1/tests/test_live_staging.py +85 -0
- cloudcruise-0.0.1/tests/test_vault_crypto.py +18 -0
- cloudcruise-0.0.1/tests/test_webhook.py +35 -0
- cloudcruise-0.0.1/tests/test_workflows_validation.py +40 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CloudCruise
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cloudcruise
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: The official CloudCruise Python SDK
|
|
5
|
+
Author-email: CloudCruise <founders@cloudcruise.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
Project-URL: Homepage, https://cloudcruise.com
|
|
8
|
+
Project-URL: Documentation, https://docs.cloudcruise.com
|
|
9
|
+
Project-URL: Repository, https://github.com/CloudCruise/cloudcruise-python
|
|
10
|
+
Project-URL: Issues, https://github.com/CloudCruise/cloudcruise-python/issues
|
|
11
|
+
Project-URL: Discord, https://discord.com/invite/MHjbUqedZF
|
|
12
|
+
Keywords: cloudcruise,sdk,automation,workflows,sse,webhook
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: requests>=2.31.0
|
|
22
|
+
Requires-Dist: cryptography>=41.0.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# cloudcruise-python
|
|
32
|
+
|
|
33
|
+
[](LICENSE)
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
[](https://github.com/CloudCruise/cloudcruise-python)
|
|
37
|
+
[](https://discord.com/invite/MHjbUqedZF)
|
|
38
|
+
[](https://www.ycombinator.com/companies/cloudcruise)
|
|
39
|
+
|
|
40
|
+
The official CloudCruise Python SDK for automated browser workflows, encrypted
|
|
41
|
+
credential management, realtime run monitoring, and webhook verification.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install cloudcruise
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Python 3.10 or newer is required. The package ships with type hints (`py.typed`).
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from cloudcruise import CloudCruise, StartRunRequest
|
|
59
|
+
|
|
60
|
+
client = CloudCruise(
|
|
61
|
+
api_key="<CLOUDCRUISE_API_KEY>",
|
|
62
|
+
encryption_key="<CLOUDCRUISE_ENCRYPTION_KEY>",
|
|
63
|
+
)
|
|
64
|
+
# Alternatively, set CLOUDCRUISE_API_KEY and CLOUDCRUISE_ENCRYPTION_KEY
|
|
65
|
+
# environment variables and instantiate with `client = CloudCruise()`.
|
|
66
|
+
|
|
67
|
+
run = client.runs.start(
|
|
68
|
+
StartRunRequest(
|
|
69
|
+
workflow_id="105b7ae1-ce62-4a5c-b782-b4b0aec5175a",
|
|
70
|
+
run_input_variables={"email": "test@example.com"},
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Listen to specific event types (recommended - clean and type-safe)
|
|
75
|
+
run.on("execution.start", lambda e: print(f"Workflow started: {e['payload']['workflow_id']}"))
|
|
76
|
+
run.on("execution.step", lambda e: print(f"Step: {e['payload']['current_step']}"))
|
|
77
|
+
run.on("execution.success", lambda e: print(f"Success! Output: {e['payload'].get('data')}"))
|
|
78
|
+
run.on("end", lambda info: print(f"Run completed: {info['type']}"))
|
|
79
|
+
|
|
80
|
+
# Or use generic listener for all events (flattened structure)
|
|
81
|
+
# run.on("run.event", lambda event: print(f"{event['type']}: {event['payload']}"))
|
|
82
|
+
|
|
83
|
+
# Block until the run finishes and fetch final results
|
|
84
|
+
result = run.wait()
|
|
85
|
+
print(result.status, result.data)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Environment variables `CLOUDCRUISE_API_KEY`, `CLOUDCRUISE_ENCRYPTION_KEY` are also supported via lazy `cloudcruise.client()`.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Clients
|
|
93
|
+
|
|
94
|
+
| Client | Description | Module Docs |
|
|
95
|
+
| ---------------------------------------- | ------------------------------------------------------ | -------------------------------------------------- |
|
|
96
|
+
| [**Vault**](./cloudcruise/vault) | AES-256-GCM credential storage and retrieval utilities | [`cloudcruise.vault`](./cloudcruise/vault) |
|
|
97
|
+
| [**Workflows**](./cloudcruise/workflows) | Workflow definitions, metadata, and input validation | [`cloudcruise.workflows`](./cloudcruise/workflows) |
|
|
98
|
+
| [**Runs**](./cloudcruise/runs) | Workflow execution with SSE-based realtime streaming | [`cloudcruise.runs`](./cloudcruise/runs) |
|
|
99
|
+
| [**Webhook**](./cloudcruise/webhook) | Webhook payload verification and helpers | [`cloudcruise.webhook`](./cloudcruise/webhook) |
|
|
100
|
+
|
|
101
|
+
All clients are accessible via `CloudCruise` or the convenience `cloudcruise.client()` singleton.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
This project uses standard Python tooling with `setuptools`. See
|
|
108
|
+
[CONTRIBUTING.md](./CONTRIBUTING.md) for comprehensive instructions.
|
|
109
|
+
|
|
110
|
+
Quick start:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python -m venv .venv
|
|
114
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
115
|
+
pip install -e ".[dev]" # installs package + dev dependencies
|
|
116
|
+
|
|
117
|
+
# Run the unit test suite
|
|
118
|
+
python -m unittest discover -s tests -p "test_*.py" -v
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For live staging tests, export `CLOUDCRUISE_API_KEY` and
|
|
122
|
+
`CLOUDCRUISE_ENCRYPTION_KEY`, then run `python -m unittest tests/test_live_staging.py -v`.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Documentation & Resources
|
|
127
|
+
|
|
128
|
+
- [API Documentation](https://docs.cloudcruise.com) – Full platform reference
|
|
129
|
+
- [CloudCruise Platform](https://cloudcruise.com) – Product overview
|
|
130
|
+
- [Agents & Assistant Context](./AGENTS.md) – How this repository’s automation assistant operates
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# cloudcruise-python
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
[](https://github.com/CloudCruise/cloudcruise-python)
|
|
7
|
+
[](https://discord.com/invite/MHjbUqedZF)
|
|
8
|
+
[](https://www.ycombinator.com/companies/cloudcruise)
|
|
9
|
+
|
|
10
|
+
The official CloudCruise Python SDK for automated browser workflows, encrypted
|
|
11
|
+
credential management, realtime run monitoring, and webhook verification.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install cloudcruise
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Python 3.10 or newer is required. The package ships with type hints (`py.typed`).
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from cloudcruise import CloudCruise, StartRunRequest
|
|
29
|
+
|
|
30
|
+
client = CloudCruise(
|
|
31
|
+
api_key="<CLOUDCRUISE_API_KEY>",
|
|
32
|
+
encryption_key="<CLOUDCRUISE_ENCRYPTION_KEY>",
|
|
33
|
+
)
|
|
34
|
+
# Alternatively, set CLOUDCRUISE_API_KEY and CLOUDCRUISE_ENCRYPTION_KEY
|
|
35
|
+
# environment variables and instantiate with `client = CloudCruise()`.
|
|
36
|
+
|
|
37
|
+
run = client.runs.start(
|
|
38
|
+
StartRunRequest(
|
|
39
|
+
workflow_id="105b7ae1-ce62-4a5c-b782-b4b0aec5175a",
|
|
40
|
+
run_input_variables={"email": "test@example.com"},
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Listen to specific event types (recommended - clean and type-safe)
|
|
45
|
+
run.on("execution.start", lambda e: print(f"Workflow started: {e['payload']['workflow_id']}"))
|
|
46
|
+
run.on("execution.step", lambda e: print(f"Step: {e['payload']['current_step']}"))
|
|
47
|
+
run.on("execution.success", lambda e: print(f"Success! Output: {e['payload'].get('data')}"))
|
|
48
|
+
run.on("end", lambda info: print(f"Run completed: {info['type']}"))
|
|
49
|
+
|
|
50
|
+
# Or use generic listener for all events (flattened structure)
|
|
51
|
+
# run.on("run.event", lambda event: print(f"{event['type']}: {event['payload']}"))
|
|
52
|
+
|
|
53
|
+
# Block until the run finishes and fetch final results
|
|
54
|
+
result = run.wait()
|
|
55
|
+
print(result.status, result.data)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Environment variables `CLOUDCRUISE_API_KEY`, `CLOUDCRUISE_ENCRYPTION_KEY` are also supported via lazy `cloudcruise.client()`.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Clients
|
|
63
|
+
|
|
64
|
+
| Client | Description | Module Docs |
|
|
65
|
+
| ---------------------------------------- | ------------------------------------------------------ | -------------------------------------------------- |
|
|
66
|
+
| [**Vault**](./cloudcruise/vault) | AES-256-GCM credential storage and retrieval utilities | [`cloudcruise.vault`](./cloudcruise/vault) |
|
|
67
|
+
| [**Workflows**](./cloudcruise/workflows) | Workflow definitions, metadata, and input validation | [`cloudcruise.workflows`](./cloudcruise/workflows) |
|
|
68
|
+
| [**Runs**](./cloudcruise/runs) | Workflow execution with SSE-based realtime streaming | [`cloudcruise.runs`](./cloudcruise/runs) |
|
|
69
|
+
| [**Webhook**](./cloudcruise/webhook) | Webhook payload verification and helpers | [`cloudcruise.webhook`](./cloudcruise/webhook) |
|
|
70
|
+
|
|
71
|
+
All clients are accessible via `CloudCruise` or the convenience `cloudcruise.client()` singleton.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
This project uses standard Python tooling with `setuptools`. See
|
|
78
|
+
[CONTRIBUTING.md](./CONTRIBUTING.md) for comprehensive instructions.
|
|
79
|
+
|
|
80
|
+
Quick start:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
python -m venv .venv
|
|
84
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
85
|
+
pip install -e ".[dev]" # installs package + dev dependencies
|
|
86
|
+
|
|
87
|
+
# Run the unit test suite
|
|
88
|
+
python -m unittest discover -s tests -p "test_*.py" -v
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For live staging tests, export `CLOUDCRUISE_API_KEY` and
|
|
92
|
+
`CLOUDCRUISE_ENCRYPTION_KEY`, then run `python -m unittest tests/test_live_staging.py -v`.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Documentation & Resources
|
|
97
|
+
|
|
98
|
+
- [API Documentation](https://docs.cloudcruise.com) – Full platform reference
|
|
99
|
+
- [CloudCruise Platform](https://cloudcruise.com) – Product overview
|
|
100
|
+
- [Agents & Assistant Context](./AGENTS.md) – How this repository’s automation assistant operates
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from .cloudcruise import CloudCruise, CloudCruiseParams
|
|
2
|
+
|
|
3
|
+
from .vault.types import (
|
|
4
|
+
VaultEntry,
|
|
5
|
+
GetVaultEntriesFilters,
|
|
6
|
+
ProxyConfig,
|
|
7
|
+
VaultPostPutHeadersInBody,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from .workflows.types import (
|
|
11
|
+
Workflow,
|
|
12
|
+
WorkflowInputSchema,
|
|
13
|
+
WorkflowMetadata,
|
|
14
|
+
InputValidationError,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
from .runs.types import (
|
|
18
|
+
EventType,
|
|
19
|
+
DryRun,
|
|
20
|
+
Metadata,
|
|
21
|
+
RunSpecificWebhook,
|
|
22
|
+
PayloadWebhook,
|
|
23
|
+
StartRunRequest,
|
|
24
|
+
StartRunResponse,
|
|
25
|
+
UserInteractionData,
|
|
26
|
+
VideoUrl,
|
|
27
|
+
FileUrl,
|
|
28
|
+
ScreenshotUrl,
|
|
29
|
+
RunError,
|
|
30
|
+
RunResult,
|
|
31
|
+
WebhookEvent,
|
|
32
|
+
WebhookReplayResponse,
|
|
33
|
+
RunHandle,
|
|
34
|
+
RunStreamOptions,
|
|
35
|
+
SseEventName,
|
|
36
|
+
SseMessage,
|
|
37
|
+
RunEventEnvelope,
|
|
38
|
+
# Event payload types
|
|
39
|
+
ExecutionQueuedPayload,
|
|
40
|
+
ExecutionStartPayload,
|
|
41
|
+
ExecutionStepPayload,
|
|
42
|
+
InteractionWaitingPayload,
|
|
43
|
+
InteractionFinishedPayload,
|
|
44
|
+
AgentErrorAnalysisPayload,
|
|
45
|
+
ExecutionRequeuedPayload,
|
|
46
|
+
EndRunPayload,
|
|
47
|
+
EndRunError,
|
|
48
|
+
ExecutionStoppedEarlyPayload,
|
|
49
|
+
FileUploadedPayload,
|
|
50
|
+
ScreenshotUploadedPayload,
|
|
51
|
+
EventWebhookMessage,
|
|
52
|
+
RunEventMessage,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
from .webhook.types import WebhookPayload, WebhookVerificationOptions, VerificationError, WebhookMessage
|
|
56
|
+
from ._default import get_client as client
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"CloudCruise",
|
|
60
|
+
"CloudCruiseParams",
|
|
61
|
+
# Default client helper
|
|
62
|
+
"client",
|
|
63
|
+
# Vault Types
|
|
64
|
+
"VaultEntry",
|
|
65
|
+
"GetVaultEntriesFilters",
|
|
66
|
+
"ProxyConfig",
|
|
67
|
+
"VaultPostPutHeadersInBody",
|
|
68
|
+
# Workflow Types
|
|
69
|
+
"Workflow",
|
|
70
|
+
"WorkflowInputSchema",
|
|
71
|
+
"WorkflowMetadata",
|
|
72
|
+
"InputValidationError",
|
|
73
|
+
# Run Types
|
|
74
|
+
"EventType",
|
|
75
|
+
"DryRun",
|
|
76
|
+
"Metadata",
|
|
77
|
+
"RunSpecificWebhook",
|
|
78
|
+
"PayloadWebhook",
|
|
79
|
+
"StartRunRequest",
|
|
80
|
+
"StartRunResponse",
|
|
81
|
+
"UserInteractionData",
|
|
82
|
+
"VideoUrl",
|
|
83
|
+
"FileUrl",
|
|
84
|
+
"ScreenshotUrl",
|
|
85
|
+
"RunError",
|
|
86
|
+
"RunResult",
|
|
87
|
+
"WebhookEvent",
|
|
88
|
+
"WebhookReplayResponse",
|
|
89
|
+
"RunHandle",
|
|
90
|
+
"RunStreamOptions",
|
|
91
|
+
"SseEventName",
|
|
92
|
+
"SseMessage",
|
|
93
|
+
"RunEventEnvelope",
|
|
94
|
+
# Event Payload Types
|
|
95
|
+
"ExecutionQueuedPayload",
|
|
96
|
+
"ExecutionStartPayload",
|
|
97
|
+
"ExecutionStepPayload",
|
|
98
|
+
"InteractionWaitingPayload",
|
|
99
|
+
"InteractionFinishedPayload",
|
|
100
|
+
"AgentErrorAnalysisPayload",
|
|
101
|
+
"ExecutionRequeuedPayload",
|
|
102
|
+
"EndRunPayload",
|
|
103
|
+
"EndRunError",
|
|
104
|
+
"ExecutionStoppedEarlyPayload",
|
|
105
|
+
"FileUploadedPayload",
|
|
106
|
+
"ScreenshotUploadedPayload",
|
|
107
|
+
"EventWebhookMessage",
|
|
108
|
+
"RunEventMessage",
|
|
109
|
+
# Webhook Types
|
|
110
|
+
"WebhookPayload",
|
|
111
|
+
"WebhookVerificationOptions",
|
|
112
|
+
"VerificationError",
|
|
113
|
+
"WebhookMessage",
|
|
114
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from .cloudcruise import CloudCruise, CloudCruiseParams
|
|
6
|
+
|
|
7
|
+
_default_client: Optional[CloudCruise] = None
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_client(
|
|
11
|
+
params: Optional[CloudCruiseParams] = None,
|
|
12
|
+
*,
|
|
13
|
+
api_key: Optional[str] = None,
|
|
14
|
+
encryption_key: Optional[str] = None,
|
|
15
|
+
base_url: Optional[str] = None,
|
|
16
|
+
) -> CloudCruise:
|
|
17
|
+
"""Return the shared default CloudCruise client.
|
|
18
|
+
|
|
19
|
+
You can configure it by passing a CloudCruiseParams instance or via
|
|
20
|
+
keyword args (api_key, encryption_key, base_url). Passing any params or
|
|
21
|
+
keyword args replaces the cached client.
|
|
22
|
+
"""
|
|
23
|
+
global _default_client
|
|
24
|
+
|
|
25
|
+
effective_params = params
|
|
26
|
+
if effective_params is None and (api_key is not None or encryption_key is not None or base_url is not None):
|
|
27
|
+
effective_params = CloudCruiseParams(api_key=api_key, encryption_key=encryption_key, base_url=base_url)
|
|
28
|
+
|
|
29
|
+
if effective_params is not None or _default_client is None:
|
|
30
|
+
_default_client = CloudCruise(effective_params)
|
|
31
|
+
return _default_client
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
import json
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from .utils.env import get_env
|
|
9
|
+
from .vault.client import VaultClient
|
|
10
|
+
from .workflows.client import WorkflowsClient
|
|
11
|
+
from .runs.client import RunsClient
|
|
12
|
+
from .webhook.client import WebhookClient
|
|
13
|
+
from .utils.connection_manager import ConnectionManager
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class CloudCruiseParams:
|
|
17
|
+
api_key: Optional[str] = None
|
|
18
|
+
base_url: Optional[str] = None
|
|
19
|
+
encryption_key: Optional[str] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CloudCruise:
|
|
23
|
+
"""
|
|
24
|
+
CloudCruise Python SDK
|
|
25
|
+
Official client library for the CloudCruise Platform
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
# Expose typed attributes for IDE autocomplete
|
|
29
|
+
vault: VaultClient
|
|
30
|
+
workflows: WorkflowsClient
|
|
31
|
+
runs: RunsClient
|
|
32
|
+
webhook: WebhookClient
|
|
33
|
+
|
|
34
|
+
def __init__(self, params: Optional[CloudCruiseParams] = None) -> None:
|
|
35
|
+
params = params or CloudCruiseParams()
|
|
36
|
+
api_key = params.api_key or get_env("CLOUDCRUISE_API_KEY")
|
|
37
|
+
base_url = params.base_url or get_env("CLOUDCRUISE_BASE_URL") or "https://api.cloudcruise.com"
|
|
38
|
+
encryption_key = params.encryption_key or get_env("CLOUDCRUISE_ENCRYPTION_KEY")
|
|
39
|
+
|
|
40
|
+
if not api_key:
|
|
41
|
+
raise ValueError("Missing apiKey. Provide via params.api_key or CLOUDCRUISE_API_KEY env var.")
|
|
42
|
+
if not encryption_key:
|
|
43
|
+
raise ValueError(
|
|
44
|
+
"Missing encryptionKey. Provide via params.encryption_key or CLOUDCRUISE_ENCRYPTION_KEY env var."
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
self._api_key = api_key
|
|
48
|
+
self._base_url = base_url.rstrip("/")
|
|
49
|
+
self._encryption_key = encryption_key
|
|
50
|
+
|
|
51
|
+
# Initialize namespace clients
|
|
52
|
+
self._connection_manager = ConnectionManager(self._base_url, self._api_key)
|
|
53
|
+
self.vault = VaultClient(self._make_request, self._encryption_key)
|
|
54
|
+
self.workflows = WorkflowsClient(self._make_request)
|
|
55
|
+
self.runs = RunsClient(self._connection_manager, self._make_request, self.workflows)
|
|
56
|
+
self.webhook = WebhookClient()
|
|
57
|
+
|
|
58
|
+
def _make_request(self, method: str, path: str, body: Optional[Any] = None) -> Any:
|
|
59
|
+
"""
|
|
60
|
+
Makes an HTTP request to the CloudCruise API
|
|
61
|
+
Automatically adds the cc-key header for authentication
|
|
62
|
+
"""
|
|
63
|
+
url = f"{self._base_url}{path}"
|
|
64
|
+
headers = {
|
|
65
|
+
"cc-key": self._api_key,
|
|
66
|
+
}
|
|
67
|
+
try:
|
|
68
|
+
# Only send Content-Type when we have a JSON body
|
|
69
|
+
if body is not None:
|
|
70
|
+
headers["Content-Type"] = "application/json"
|
|
71
|
+
|
|
72
|
+
resp = requests.request(
|
|
73
|
+
method=method,
|
|
74
|
+
url=url,
|
|
75
|
+
headers=headers,
|
|
76
|
+
data=(json.dumps(body) if body is not None else None),
|
|
77
|
+
timeout=60,
|
|
78
|
+
)
|
|
79
|
+
if not resp.ok:
|
|
80
|
+
error_text = resp.text
|
|
81
|
+
error_message = f"HTTP {resp.status_code}: {resp.reason}"
|
|
82
|
+
try:
|
|
83
|
+
error_json = resp.json()
|
|
84
|
+
error_message = error_json.get("message") or error_json.get("error") or error_message
|
|
85
|
+
except Exception:
|
|
86
|
+
pass
|
|
87
|
+
raise RuntimeError(error_message)
|
|
88
|
+
|
|
89
|
+
ctype = resp.headers.get("content-type", "")
|
|
90
|
+
if "application/json" in ctype:
|
|
91
|
+
return resp.json()
|
|
92
|
+
|
|
93
|
+
else:
|
|
94
|
+
return resp.text
|
|
95
|
+
except Exception as e:
|
|
96
|
+
raise e
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .types import (
|
|
4
|
+
ExecutionQueuedPayload,
|
|
5
|
+
ExecutionStartPayload,
|
|
6
|
+
ExecutionStepPayload,
|
|
7
|
+
InteractionWaitingPayload,
|
|
8
|
+
InteractionFinishedPayload,
|
|
9
|
+
InteractionFinishedPayloadVariant1,
|
|
10
|
+
InteractionFinishedPayloadVariant2,
|
|
11
|
+
AgentErrorAnalysisPayload,
|
|
12
|
+
ExecutionRequeuedPayload,
|
|
13
|
+
EndRunPayload,
|
|
14
|
+
EndRunError,
|
|
15
|
+
ExecutionStoppedEarlyPayload,
|
|
16
|
+
FileUploadedPayload,
|
|
17
|
+
ScreenshotUploadedPayload,
|
|
18
|
+
WebhookMessage,
|
|
19
|
+
RunEventMessage,
|
|
20
|
+
RunEventMessageData,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
# Event payload types
|
|
25
|
+
"ExecutionQueuedPayload",
|
|
26
|
+
"ExecutionStartPayload",
|
|
27
|
+
"ExecutionStepPayload",
|
|
28
|
+
"InteractionWaitingPayload",
|
|
29
|
+
"InteractionFinishedPayload",
|
|
30
|
+
"InteractionFinishedPayloadVariant1",
|
|
31
|
+
"InteractionFinishedPayloadVariant2",
|
|
32
|
+
"AgentErrorAnalysisPayload",
|
|
33
|
+
"ExecutionRequeuedPayload",
|
|
34
|
+
"EndRunPayload",
|
|
35
|
+
"EndRunError",
|
|
36
|
+
"ExecutionStoppedEarlyPayload",
|
|
37
|
+
"FileUploadedPayload",
|
|
38
|
+
"ScreenshotUploadedPayload",
|
|
39
|
+
# Generic message types
|
|
40
|
+
"WebhookMessage",
|
|
41
|
+
"RunEventMessage",
|
|
42
|
+
"RunEventMessageData",
|
|
43
|
+
]
|