leashbyte-sdk 0.1.1__py3-none-any.whl
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.
- leashbyte_sdk/__init__.py +54 -0
- leashbyte_sdk/_models.py +264 -0
- leashbyte_sdk/client.py +345 -0
- leashbyte_sdk-0.1.1.dist-info/METADATA +52 -0
- leashbyte_sdk-0.1.1.dist-info/RECORD +8 -0
- leashbyte_sdk-0.1.1.dist-info/WHEEL +4 -0
- leashbyte_sdk-0.1.1.dist-info/licenses/LICENSE +203 -0
- leashbyte_sdk-0.1.1.dist-info/licenses/NOTICE +6 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Public models and client for the LeashByte Python SDK."""
|
|
2
|
+
|
|
3
|
+
from ._models import (
|
|
4
|
+
BrowserActionRequest,
|
|
5
|
+
BrowserCloseResponse,
|
|
6
|
+
BrowserNode,
|
|
7
|
+
BrowserSessionRequest,
|
|
8
|
+
BrowserSessionResponse,
|
|
9
|
+
BrowserSnapshotResponse,
|
|
10
|
+
CancelRunRequest,
|
|
11
|
+
CdpGrantResponse,
|
|
12
|
+
ConfigResponse,
|
|
13
|
+
CredentialListResponse,
|
|
14
|
+
CredentialMetadata,
|
|
15
|
+
CredentialRequest,
|
|
16
|
+
FetchRequest,
|
|
17
|
+
FetchResponse,
|
|
18
|
+
RunCreateRequest,
|
|
19
|
+
RunLimits,
|
|
20
|
+
RunListResponse,
|
|
21
|
+
RunResponse,
|
|
22
|
+
SearchResponse,
|
|
23
|
+
SearchResult,
|
|
24
|
+
StepResponse,
|
|
25
|
+
)
|
|
26
|
+
from .client import TERMINAL_RUN_STATES, ApiError, LeashByteClient, LeashByteError
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"TERMINAL_RUN_STATES",
|
|
30
|
+
"ApiError",
|
|
31
|
+
"BrowserActionRequest",
|
|
32
|
+
"BrowserCloseResponse",
|
|
33
|
+
"BrowserNode",
|
|
34
|
+
"BrowserSessionRequest",
|
|
35
|
+
"BrowserSessionResponse",
|
|
36
|
+
"BrowserSnapshotResponse",
|
|
37
|
+
"CancelRunRequest",
|
|
38
|
+
"CdpGrantResponse",
|
|
39
|
+
"ConfigResponse",
|
|
40
|
+
"CredentialListResponse",
|
|
41
|
+
"CredentialMetadata",
|
|
42
|
+
"CredentialRequest",
|
|
43
|
+
"FetchRequest",
|
|
44
|
+
"FetchResponse",
|
|
45
|
+
"LeashByteClient",
|
|
46
|
+
"LeashByteError",
|
|
47
|
+
"RunCreateRequest",
|
|
48
|
+
"RunLimits",
|
|
49
|
+
"RunListResponse",
|
|
50
|
+
"RunResponse",
|
|
51
|
+
"SearchResponse",
|
|
52
|
+
"SearchResult",
|
|
53
|
+
"StepResponse",
|
|
54
|
+
]
|
leashbyte_sdk/_models.py
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# generated by datamodel-codegen:
|
|
2
|
+
# filename: openapi.json
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Annotated, Any, Literal
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, ConfigDict, Field, RootModel, SecretStr
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Mark(RootModel[int]):
|
|
12
|
+
root: Annotated[int, Field(ge=1, title="Mark")]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Url(RootModel[str]):
|
|
16
|
+
root: Annotated[str, Field(max_length=2048, title="Url")]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Text(RootModel[str]):
|
|
20
|
+
root: Annotated[str, Field(max_length=100000, title="Text")]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Values(RootModel[list[str]]):
|
|
24
|
+
root: Annotated[list[str], Field(max_length=20, title="Values")]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Placeholder(RootModel[str]):
|
|
28
|
+
root: Annotated[str, Field(max_length=256, title="Placeholder")]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class BrowserActionRequest(BaseModel):
|
|
32
|
+
action: Annotated[
|
|
33
|
+
Literal["navigate", "click", "type", "select", "scroll", "fill_secret"],
|
|
34
|
+
Field(title="Action"),
|
|
35
|
+
]
|
|
36
|
+
snapshot_id: Annotated[str, Field(max_length=64, min_length=8, title="Snapshot Id")]
|
|
37
|
+
mark: Annotated[Mark | None, Field(title="Mark")] = None
|
|
38
|
+
url: Annotated[Url | None, Field(title="Url")] = None
|
|
39
|
+
text: Annotated[Text | None, Field(title="Text")] = None
|
|
40
|
+
values: Annotated[Values | None, Field(title="Values")] = None
|
|
41
|
+
placeholder: Annotated[Placeholder | None, Field(title="Placeholder")] = None
|
|
42
|
+
x: Annotated[int | None, Field(ge=-10000, le=10000, title="X")] = 0
|
|
43
|
+
y: Annotated[int | None, Field(ge=-10000, le=10000, title="Y")] = 0
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class BrowserCloseResponse(BaseModel):
|
|
47
|
+
id: Annotated[str, Field(title="Id")]
|
|
48
|
+
state: Annotated[str, Field(title="State")]
|
|
49
|
+
profile_released: Annotated[bool, Field(title="Profile Released")]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class BrowserNode(BaseModel):
|
|
53
|
+
mark: Annotated[int, Field(title="Mark")]
|
|
54
|
+
tag: Annotated[str, Field(title="Tag")]
|
|
55
|
+
role: Annotated[str, Field(title="Role")]
|
|
56
|
+
name: Annotated[str, Field(title="Name")]
|
|
57
|
+
input_type: Annotated[str | None, Field(title="Input Type")]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class StartUrl(RootModel[str]):
|
|
61
|
+
root: Annotated[str, Field(max_length=2048, title="Start Url")]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Proxy(RootModel[str]):
|
|
65
|
+
root: Annotated[str, Field(max_length=2048, title="Proxy")]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class LeaseSeconds(RootModel[int]):
|
|
69
|
+
root: Annotated[int, Field(ge=30, le=3600, title="Lease Seconds")]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class BrowserSessionRequest(BaseModel):
|
|
73
|
+
profile: Annotated[str, Field(max_length=64, min_length=1, title="Profile")]
|
|
74
|
+
start_url: Annotated[StartUrl | None, Field(title="Start Url")] = None
|
|
75
|
+
proxy: Annotated[Proxy | None, Field(title="Proxy")] = None
|
|
76
|
+
lease_seconds: Annotated[LeaseSeconds | None, Field(title="Lease Seconds")] = None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class BrowserSessionResponse(BaseModel):
|
|
80
|
+
id: Annotated[str, Field(title="Id")]
|
|
81
|
+
profile: Annotated[str, Field(title="Profile")]
|
|
82
|
+
state: Annotated[str, Field(title="State")]
|
|
83
|
+
current_url: Annotated[str, Field(title="Current Url")]
|
|
84
|
+
expires_at: Annotated[str, Field(title="Expires At")]
|
|
85
|
+
capabilities: Annotated[list[str], Field(title="Capabilities")]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class BrowserSnapshotResponse(BaseModel):
|
|
89
|
+
session_id: Annotated[str, Field(title="Session Id")]
|
|
90
|
+
snapshot_id: Annotated[str, Field(title="Snapshot Id")]
|
|
91
|
+
url: Annotated[str, Field(title="Url")]
|
|
92
|
+
title: Annotated[str, Field(title="Title")]
|
|
93
|
+
nodes: Annotated[list[BrowserNode], Field(title="Nodes")]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class CancelRunRequest(BaseModel):
|
|
97
|
+
model_config = ConfigDict(
|
|
98
|
+
extra="forbid",
|
|
99
|
+
)
|
|
100
|
+
reason: Annotated[str | None, Field(max_length=300, min_length=1, title="Reason")] = (
|
|
101
|
+
"Cancelled by the user."
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class CdpGrantResponse(BaseModel):
|
|
106
|
+
session_id: Annotated[str, Field(title="Session Id")]
|
|
107
|
+
token: Annotated[str, Field(title="Token")]
|
|
108
|
+
expires_in: Annotated[int, Field(title="Expires In")]
|
|
109
|
+
path: Annotated[str, Field(title="Path")]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class ConfigResponse(BaseModel):
|
|
113
|
+
version: Annotated[str, Field(title="Version")]
|
|
114
|
+
features: Annotated[dict[str, bool], Field(title="Features")]
|
|
115
|
+
limits: Annotated[dict[str, int | float], Field(title="Limits")]
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class CredentialMetadata(BaseModel):
|
|
119
|
+
alias: Annotated[str, Field(title="Alias")]
|
|
120
|
+
allowed_origins: Annotated[list[str], Field(title="Allowed Origins")]
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class CredentialRequest(BaseModel):
|
|
124
|
+
alias: Annotated[str, Field(max_length=64, min_length=1, title="Alias")]
|
|
125
|
+
username: Annotated[SecretStr, Field(max_length=4096, min_length=1, title="Username")]
|
|
126
|
+
password: Annotated[SecretStr, Field(max_length=16384, min_length=1, title="Password")]
|
|
127
|
+
allowed_origins: Annotated[
|
|
128
|
+
list[str], Field(max_length=20, min_length=1, title="Allowed Origins")
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class TimeoutSeconds(RootModel[float]):
|
|
133
|
+
root: Annotated[float, Field(gt=0.0, le=120.0, title="Timeout Seconds")]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class MaxBytes(RootModel[int]):
|
|
137
|
+
root: Annotated[int, Field(gt=0, le=20000000, title="Max Bytes")]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class FetchRequest(BaseModel):
|
|
141
|
+
url: Annotated[str, Field(max_length=2048, min_length=1, title="Url")]
|
|
142
|
+
format: Annotated[Literal["markdown", "html", "json"] | None, Field(title="Format")] = (
|
|
143
|
+
"markdown"
|
|
144
|
+
)
|
|
145
|
+
timeout_seconds: Annotated[TimeoutSeconds | None, Field(title="Timeout Seconds")] = None
|
|
146
|
+
max_bytes: Annotated[MaxBytes | None, Field(title="Max Bytes")] = None
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class FetchResponse(BaseModel):
|
|
150
|
+
url: Annotated[str, Field(title="Url")]
|
|
151
|
+
final_url: Annotated[str, Field(title="Final Url")]
|
|
152
|
+
status: Annotated[int, Field(title="Status")]
|
|
153
|
+
content_type: Annotated[str, Field(title="Content Type")]
|
|
154
|
+
format: Annotated[Literal["markdown", "html", "json"], Field(title="Format")]
|
|
155
|
+
content: Annotated[
|
|
156
|
+
str | dict[str, Any] | list[Any] | int | float | bool | None,
|
|
157
|
+
Field(title="Content"),
|
|
158
|
+
]
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class Model(RootModel[str]):
|
|
162
|
+
root: Annotated[str, Field(max_length=128, title="Model")]
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class RunLimits(BaseModel):
|
|
166
|
+
"""
|
|
167
|
+
User limits that the worker cannot exceed.
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
model_config = ConfigDict(
|
|
171
|
+
extra="forbid",
|
|
172
|
+
)
|
|
173
|
+
steps: Annotated[int | None, Field(ge=1, le=100, title="Steps")] = 12
|
|
174
|
+
elapsed_seconds: Annotated[int | None, Field(ge=10, le=3600, title="Elapsed Seconds")] = 600
|
|
175
|
+
tokens: Annotated[int | None, Field(ge=100, le=100000, title="Tokens")] = 12000
|
|
176
|
+
navigations: Annotated[int | None, Field(ge=0, le=50, title="Navigations")] = 5
|
|
177
|
+
artifact_bytes: Annotated[int | None, Field(ge=1024, le=20000000, title="Artifact Bytes")] = (
|
|
178
|
+
5000000
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class RunResponse(BaseModel):
|
|
183
|
+
id: Annotated[str, Field(title="Id")]
|
|
184
|
+
goal: Annotated[str, Field(title="Goal")]
|
|
185
|
+
state: Annotated[str, Field(title="State")]
|
|
186
|
+
created_at: Annotated[str, Field(title="Created At")]
|
|
187
|
+
started_at: Annotated[str | None, Field(title="Started At")]
|
|
188
|
+
finished_at: Annotated[str | None, Field(title="Finished At")]
|
|
189
|
+
provider: Annotated[str, Field(title="Provider")]
|
|
190
|
+
model: Annotated[str, Field(title="Model")]
|
|
191
|
+
profile: Annotated[str, Field(title="Profile")]
|
|
192
|
+
session_id: Annotated[str | None, Field(title="Session Id")]
|
|
193
|
+
start_url: Annotated[str, Field(title="Start Url")]
|
|
194
|
+
step_count: Annotated[int, Field(title="Step Count")]
|
|
195
|
+
usage: Annotated[dict[str, Any], Field(title="Usage")]
|
|
196
|
+
result: Annotated[dict[str, Any] | None, Field(title="Result")]
|
|
197
|
+
error: Annotated[str | None, Field(title="Error")]
|
|
198
|
+
cancellation_reason: Annotated[str | None, Field(title="Cancellation Reason")]
|
|
199
|
+
artifact_bytes: Annotated[int, Field(title="Artifact Bytes")]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class SearchResult(BaseModel):
|
|
203
|
+
title: Annotated[str, Field(title="Title")]
|
|
204
|
+
url: Annotated[str, Field(title="Url")]
|
|
205
|
+
snippet: Annotated[str, Field(title="Snippet")]
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class StepResponse(BaseModel):
|
|
209
|
+
number: Annotated[int, Field(title="Number")]
|
|
210
|
+
snapshot_id: Annotated[str, Field(title="Snapshot Id")]
|
|
211
|
+
action: Annotated[dict[str, Any], Field(title="Action")]
|
|
212
|
+
before_observation: Annotated[dict[str, Any], Field(title="Before Observation")]
|
|
213
|
+
after_observation: Annotated[dict[str, Any] | None, Field(title="After Observation")]
|
|
214
|
+
source_url: Annotated[str | None, Field(title="Source Url")]
|
|
215
|
+
error: Annotated[str | None, Field(title="Error")]
|
|
216
|
+
created_at: Annotated[str, Field(title="Created At")]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class ValidationError(BaseModel):
|
|
220
|
+
loc: Annotated[list[str | int], Field(title="Location")]
|
|
221
|
+
msg: Annotated[str, Field(title="Message")]
|
|
222
|
+
type: Annotated[str, Field(title="Error Type")]
|
|
223
|
+
input: Annotated[Any | None, Field(title="Input")] = None
|
|
224
|
+
ctx: Annotated[dict[str, Any] | None, Field(title="Context")] = None
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class CredentialListResponse(BaseModel):
|
|
228
|
+
credentials: Annotated[list[CredentialMetadata], Field(title="Credentials")]
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class HTTPValidationError(BaseModel):
|
|
232
|
+
detail: Annotated[list[ValidationError] | None, Field(title="Detail")] = None
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class RunCreateRequest(BaseModel):
|
|
236
|
+
"""
|
|
237
|
+
A goal and the fixed policy for one agent run.
|
|
238
|
+
"""
|
|
239
|
+
|
|
240
|
+
model_config = ConfigDict(
|
|
241
|
+
extra="forbid",
|
|
242
|
+
)
|
|
243
|
+
goal: Annotated[str, Field(max_length=4000, min_length=1, title="Goal")]
|
|
244
|
+
start_url: Annotated[str, Field(max_length=2048, min_length=1, title="Start Url")]
|
|
245
|
+
profile: Annotated[str | None, Field(max_length=64, min_length=1, title="Profile")] = "agent"
|
|
246
|
+
provider: Annotated[Literal["local", "anthropic"] | None, Field(title="Provider")] = "local"
|
|
247
|
+
model: Annotated[Model | None, Field(title="Model")] = None
|
|
248
|
+
credential_aliases: Annotated[
|
|
249
|
+
list[str] | None, Field(max_length=10, title="Credential Aliases")
|
|
250
|
+
] = None
|
|
251
|
+
allowed_origins: Annotated[list[str] | None, Field(max_length=20, title="Allowed Origins")] = (
|
|
252
|
+
None
|
|
253
|
+
)
|
|
254
|
+
limits: RunLimits | None = None
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class RunListResponse(BaseModel):
|
|
258
|
+
runs: Annotated[list[RunResponse], Field(title="Runs")]
|
|
259
|
+
next_cursor: Annotated[str | None, Field(title="Next Cursor")]
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class SearchResponse(BaseModel):
|
|
263
|
+
query: Annotated[str, Field(title="Query")]
|
|
264
|
+
results: Annotated[list[SearchResult], Field(title="Results")]
|
leashbyte_sdk/client.py
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"""Synchronous Python client for the stable LeashByte API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import time
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, TypeVar
|
|
10
|
+
from urllib.parse import quote, urlsplit
|
|
11
|
+
|
|
12
|
+
import httpx
|
|
13
|
+
from pydantic import BaseModel, SecretStr
|
|
14
|
+
|
|
15
|
+
from ._models import (
|
|
16
|
+
BrowserActionRequest,
|
|
17
|
+
BrowserCloseResponse,
|
|
18
|
+
BrowserSessionRequest,
|
|
19
|
+
BrowserSessionResponse,
|
|
20
|
+
BrowserSnapshotResponse,
|
|
21
|
+
CancelRunRequest,
|
|
22
|
+
CdpGrantResponse,
|
|
23
|
+
ConfigResponse,
|
|
24
|
+
CredentialListResponse,
|
|
25
|
+
CredentialMetadata,
|
|
26
|
+
CredentialRequest,
|
|
27
|
+
FetchRequest,
|
|
28
|
+
FetchResponse,
|
|
29
|
+
RunCreateRequest,
|
|
30
|
+
RunListResponse,
|
|
31
|
+
RunResponse,
|
|
32
|
+
SearchResponse,
|
|
33
|
+
StepResponse,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
ModelT = TypeVar("ModelT", bound=BaseModel)
|
|
37
|
+
TERMINAL_RUN_STATES = frozenset({"succeeded", "failed", "cancelled", "limit_reached"})
|
|
38
|
+
_BEARER = re.compile(r"(?i)(bearer\s+)[^\s,;]+")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _secret_value(value: Any) -> Any:
|
|
42
|
+
if isinstance(value, SecretStr):
|
|
43
|
+
return value.get_secret_value()
|
|
44
|
+
if isinstance(value, dict):
|
|
45
|
+
return {key: _secret_value(item) for key, item in value.items()}
|
|
46
|
+
if isinstance(value, list):
|
|
47
|
+
return [_secret_value(item) for item in value]
|
|
48
|
+
return value
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class LeashByteError(Exception):
|
|
52
|
+
"""A safe error that never contains a configured key."""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ApiError(LeashByteError):
|
|
56
|
+
"""An error response from the API."""
|
|
57
|
+
|
|
58
|
+
def __init__(self, status: int, code: str, message: str, request_id: str | None = None) -> None:
|
|
59
|
+
super().__init__(message)
|
|
60
|
+
self.status = status
|
|
61
|
+
self.code = code
|
|
62
|
+
self.request_id = request_id
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class LeashByteClient:
|
|
66
|
+
"""Call the REST API with an API key from an argument or the environment."""
|
|
67
|
+
|
|
68
|
+
def __init__(
|
|
69
|
+
self,
|
|
70
|
+
base_url: str = "http://127.0.0.1:8080",
|
|
71
|
+
api_key: str | None = None,
|
|
72
|
+
*,
|
|
73
|
+
timeout_seconds: float = 30,
|
|
74
|
+
transport: httpx.BaseTransport | None = None,
|
|
75
|
+
) -> None:
|
|
76
|
+
parsed = urlsplit(base_url)
|
|
77
|
+
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
|
78
|
+
raise ValueError("The base URL must use HTTP or HTTPS and include a host.")
|
|
79
|
+
if parsed.username or parsed.password or parsed.query or parsed.fragment:
|
|
80
|
+
raise ValueError("The base URL cannot contain credentials, a query or a fragment.")
|
|
81
|
+
key_file = os.environ.get("LEASHBYTE_API_KEY_FILE")
|
|
82
|
+
if api_key is None and key_file:
|
|
83
|
+
api_key = Path(key_file).read_text(encoding="utf-8").strip()
|
|
84
|
+
api_key = api_key or os.environ.get("LEASHBYTE_API_KEY")
|
|
85
|
+
if not api_key:
|
|
86
|
+
raise ValueError("Set api_key, LEASHBYTE_API_KEY or LEASHBYTE_API_KEY_FILE.")
|
|
87
|
+
self.base_url = base_url.rstrip("/")
|
|
88
|
+
secret_key = SecretStr(api_key)
|
|
89
|
+
del api_key
|
|
90
|
+
self._api_key = secret_key
|
|
91
|
+
self._client = httpx.Client(
|
|
92
|
+
base_url=self.base_url,
|
|
93
|
+
timeout=timeout_seconds,
|
|
94
|
+
transport=transport,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def __repr__(self) -> str:
|
|
98
|
+
return f"LeashByteClient(base_url={self.base_url!r}, api_key='[redacted]')"
|
|
99
|
+
|
|
100
|
+
def close(self) -> None:
|
|
101
|
+
self._client.close()
|
|
102
|
+
|
|
103
|
+
def __enter__(self) -> LeashByteClient:
|
|
104
|
+
return self
|
|
105
|
+
|
|
106
|
+
def __exit__(self, *_: object) -> None:
|
|
107
|
+
self.close()
|
|
108
|
+
|
|
109
|
+
def _safe_text(self, value: str, extra_secrets: tuple[str | SecretStr, ...] = ()) -> str:
|
|
110
|
+
result = _BEARER.sub(r"\1[redacted]", value)
|
|
111
|
+
for configured in (self._api_key, *extra_secrets):
|
|
112
|
+
secret = (
|
|
113
|
+
configured.get_secret_value() if isinstance(configured, SecretStr) else configured
|
|
114
|
+
)
|
|
115
|
+
if secret:
|
|
116
|
+
result = result.replace(secret, "[redacted]")
|
|
117
|
+
result = result.replace(quote(secret, safe=""), "[redacted]")
|
|
118
|
+
return result[:2000]
|
|
119
|
+
|
|
120
|
+
def _request(
|
|
121
|
+
self,
|
|
122
|
+
method: str,
|
|
123
|
+
path: str,
|
|
124
|
+
*,
|
|
125
|
+
response_type: type[ModelT] | None = None,
|
|
126
|
+
body: BaseModel | None = None,
|
|
127
|
+
params: dict[str, Any] | None = None,
|
|
128
|
+
headers: dict[str, str] | None = None,
|
|
129
|
+
binary: bool = False,
|
|
130
|
+
extra_secrets: tuple[str | SecretStr, ...] = (),
|
|
131
|
+
) -> ModelT | bytes | None:
|
|
132
|
+
json_body = _secret_value(body.model_dump(exclude_none=True)) if body else None
|
|
133
|
+
query = {key: value for key, value in (params or {}).items() if value is not None}
|
|
134
|
+
failure = None
|
|
135
|
+
try:
|
|
136
|
+
response = self._client.request(
|
|
137
|
+
method,
|
|
138
|
+
path,
|
|
139
|
+
json=json_body,
|
|
140
|
+
params=query,
|
|
141
|
+
headers={
|
|
142
|
+
"X-API-Key": self._api_key.get_secret_value(),
|
|
143
|
+
**(headers or {}),
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
response.request.headers.pop("X-API-Key", None)
|
|
147
|
+
response.request.headers.pop("X-CDP-Key", None)
|
|
148
|
+
except httpx.HTTPError as error:
|
|
149
|
+
failure = type(error).__name__
|
|
150
|
+
finally:
|
|
151
|
+
del json_body, headers
|
|
152
|
+
if failure is not None:
|
|
153
|
+
message = self._safe_text(f"The API request failed with {failure}.", extra_secrets)
|
|
154
|
+
raise LeashByteError(message) from None
|
|
155
|
+
if response.status_code >= 400:
|
|
156
|
+
status = response.status_code
|
|
157
|
+
code = "http_error"
|
|
158
|
+
message = f"The API returned HTTP {status}."
|
|
159
|
+
request_id = self._safe_text(response.headers.get("X-Request-ID", ""), extra_secrets)
|
|
160
|
+
payload = None
|
|
161
|
+
error = None
|
|
162
|
+
try:
|
|
163
|
+
payload = response.json()
|
|
164
|
+
error = payload.get("error", {})
|
|
165
|
+
code = self._safe_text(str(error.get("code", code)), extra_secrets)
|
|
166
|
+
message = self._safe_text(str(error.get("message", message)), extra_secrets)
|
|
167
|
+
except (ValueError, AttributeError):
|
|
168
|
+
pass
|
|
169
|
+
finally:
|
|
170
|
+
del response, payload, error
|
|
171
|
+
raise ApiError(status, code, message, request_id or None)
|
|
172
|
+
if binary:
|
|
173
|
+
return response.content
|
|
174
|
+
if response.status_code == 204:
|
|
175
|
+
return None
|
|
176
|
+
payload = None
|
|
177
|
+
try:
|
|
178
|
+
payload = response.json()
|
|
179
|
+
return response_type.model_validate(payload) if response_type else payload
|
|
180
|
+
except (ValueError, TypeError) as error:
|
|
181
|
+
error_type = type(error).__name__
|
|
182
|
+
del response, payload
|
|
183
|
+
raise LeashByteError(
|
|
184
|
+
self._safe_text(
|
|
185
|
+
f"The API returned an invalid response with {error_type}.",
|
|
186
|
+
extra_secrets,
|
|
187
|
+
)
|
|
188
|
+
) from None
|
|
189
|
+
|
|
190
|
+
@staticmethod
|
|
191
|
+
def _segment(value: str) -> str:
|
|
192
|
+
if value in {"", ".", ".."}:
|
|
193
|
+
raise ValueError("An identifier cannot be empty or a relative path segment.")
|
|
194
|
+
return quote(value, safe="")
|
|
195
|
+
|
|
196
|
+
def health(self) -> dict[str, str]:
|
|
197
|
+
return self._request("GET", "/healthz")
|
|
198
|
+
|
|
199
|
+
def ready(self) -> dict[str, str]:
|
|
200
|
+
return self._request("GET", "/readyz")
|
|
201
|
+
|
|
202
|
+
def get_config(self) -> ConfigResponse:
|
|
203
|
+
return self._request("GET", "/v1/config", response_type=ConfigResponse)
|
|
204
|
+
|
|
205
|
+
def search(
|
|
206
|
+
self, query: str, *, limit: int = 10, language: str = "en", safe_search: int = 1
|
|
207
|
+
) -> SearchResponse:
|
|
208
|
+
return self._request(
|
|
209
|
+
"GET",
|
|
210
|
+
"/v1/search",
|
|
211
|
+
params={"q": query, "limit": limit, "language": language, "safe_search": safe_search},
|
|
212
|
+
response_type=SearchResponse,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
def fetch(self, request: FetchRequest) -> FetchResponse:
|
|
216
|
+
return self._request("POST", "/v1/fetch", body=request, response_type=FetchResponse)
|
|
217
|
+
|
|
218
|
+
def create_browser_session(self, request: BrowserSessionRequest) -> BrowserSessionResponse:
|
|
219
|
+
return self._request(
|
|
220
|
+
"POST", "/v1/browser/sessions", body=request, response_type=BrowserSessionResponse
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
def get_browser_session(self, session_id: str) -> BrowserSessionResponse:
|
|
224
|
+
return self._request(
|
|
225
|
+
"GET",
|
|
226
|
+
f"/v1/browser/sessions/{self._segment(session_id)}",
|
|
227
|
+
response_type=BrowserSessionResponse,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
def close_browser_session(self, session_id: str) -> BrowserCloseResponse:
|
|
231
|
+
return self._request(
|
|
232
|
+
"DELETE",
|
|
233
|
+
f"/v1/browser/sessions/{self._segment(session_id)}",
|
|
234
|
+
response_type=BrowserCloseResponse,
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
def browser_snapshot(self, session_id: str) -> BrowserSnapshotResponse:
|
|
238
|
+
return self._request(
|
|
239
|
+
"GET",
|
|
240
|
+
f"/v1/browser/sessions/{self._segment(session_id)}/snapshot",
|
|
241
|
+
response_type=BrowserSnapshotResponse,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
def browser_action(
|
|
245
|
+
self, session_id: str, request: BrowserActionRequest
|
|
246
|
+
) -> BrowserSnapshotResponse:
|
|
247
|
+
return self._request(
|
|
248
|
+
"POST",
|
|
249
|
+
f"/v1/browser/sessions/{self._segment(session_id)}/actions",
|
|
250
|
+
body=request,
|
|
251
|
+
response_type=BrowserSnapshotResponse,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
def browser_screenshot(self, session_id: str) -> bytes:
|
|
255
|
+
return self._request(
|
|
256
|
+
"GET", f"/v1/browser/sessions/{self._segment(session_id)}/screenshot", binary=True
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
def cdp_grant(self, session_id: str, cdp_key: str) -> CdpGrantResponse:
|
|
260
|
+
secret = SecretStr(cdp_key)
|
|
261
|
+
del cdp_key
|
|
262
|
+
return self._request(
|
|
263
|
+
"GET",
|
|
264
|
+
f"/v1/browser/sessions/{self._segment(session_id)}/cdp",
|
|
265
|
+
headers={"X-CDP-Key": secret.get_secret_value()},
|
|
266
|
+
response_type=CdpGrantResponse,
|
|
267
|
+
extra_secrets=(secret,),
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
def create_credential(self, request: CredentialRequest) -> CredentialMetadata:
|
|
271
|
+
return self._request(
|
|
272
|
+
"POST", "/v1/vault/credentials", body=request, response_type=CredentialMetadata
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
def list_credentials(self) -> CredentialListResponse:
|
|
276
|
+
return self._request("GET", "/v1/vault/credentials", response_type=CredentialListResponse)
|
|
277
|
+
|
|
278
|
+
def replace_credential(self, request: CredentialRequest) -> CredentialMetadata:
|
|
279
|
+
return self._request(
|
|
280
|
+
"PUT",
|
|
281
|
+
f"/v1/vault/credentials/{self._segment(request.alias)}",
|
|
282
|
+
body=request,
|
|
283
|
+
response_type=CredentialMetadata,
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
def delete_credential(self, alias: str) -> None:
|
|
287
|
+
self._request("DELETE", f"/v1/vault/credentials/{self._segment(alias)}")
|
|
288
|
+
|
|
289
|
+
def create_run(self, request: RunCreateRequest) -> RunResponse:
|
|
290
|
+
return self._request("POST", "/v1/runs", body=request, response_type=RunResponse)
|
|
291
|
+
|
|
292
|
+
def list_runs(self, *, limit: int = 50, cursor: str | None = None) -> RunListResponse:
|
|
293
|
+
return self._request(
|
|
294
|
+
"GET",
|
|
295
|
+
"/v1/runs",
|
|
296
|
+
params={"limit": limit, "cursor": cursor},
|
|
297
|
+
response_type=RunListResponse,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
def get_run(self, run_id: str) -> RunResponse:
|
|
301
|
+
return self._request("GET", f"/v1/runs/{self._segment(run_id)}", response_type=RunResponse)
|
|
302
|
+
|
|
303
|
+
def get_run_steps(self, run_id: str) -> list[StepResponse]:
|
|
304
|
+
path = f"/v1/runs/{self._segment(run_id)}/steps"
|
|
305
|
+
payload = self._request("GET", path)
|
|
306
|
+
if not isinstance(payload, list):
|
|
307
|
+
raise LeashByteError("The API returned an invalid run steps response.")
|
|
308
|
+
try:
|
|
309
|
+
return [StepResponse.model_validate(item) for item in payload]
|
|
310
|
+
except (ValueError, TypeError) as error:
|
|
311
|
+
raise LeashByteError(
|
|
312
|
+
f"The API returned invalid run steps with {type(error).__name__}."
|
|
313
|
+
) from None
|
|
314
|
+
|
|
315
|
+
def run_artifact(self, run_id: str, name: str) -> bytes:
|
|
316
|
+
return self._request(
|
|
317
|
+
"GET",
|
|
318
|
+
f"/v1/runs/{self._segment(run_id)}/artifacts/{self._segment(name)}",
|
|
319
|
+
binary=True,
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
def cancel_run(self, run_id: str, reason: str = "Cancelled by the user.") -> RunResponse:
|
|
323
|
+
return self._request(
|
|
324
|
+
"POST",
|
|
325
|
+
f"/v1/runs/{self._segment(run_id)}/cancel",
|
|
326
|
+
body=CancelRunRequest(reason=reason),
|
|
327
|
+
response_type=RunResponse,
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
def delete_run(self, run_id: str) -> None:
|
|
331
|
+
self._request("DELETE", f"/v1/runs/{self._segment(run_id)}")
|
|
332
|
+
|
|
333
|
+
def wait_for_run(
|
|
334
|
+
self, run_id: str, *, timeout_seconds: float = 600, interval_seconds: float = 1
|
|
335
|
+
) -> RunResponse:
|
|
336
|
+
if timeout_seconds <= 0 or interval_seconds <= 0:
|
|
337
|
+
raise ValueError("The polling timeout and interval must be greater than zero.")
|
|
338
|
+
deadline = time.monotonic() + timeout_seconds
|
|
339
|
+
while True:
|
|
340
|
+
run = self.get_run(run_id)
|
|
341
|
+
if run.state in TERMINAL_RUN_STATES:
|
|
342
|
+
return run
|
|
343
|
+
if time.monotonic() >= deadline:
|
|
344
|
+
raise LeashByteError("The run did not finish before the polling timeout.")
|
|
345
|
+
time.sleep(min(interval_seconds, max(0, deadline - time.monotonic())))
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: leashbyte-sdk
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Python client for the LeashByte API
|
|
5
|
+
Project-URL: Homepage, https://leashbyte.com
|
|
6
|
+
Project-URL: Repository, https://github.com/mangybyte/leashbyte
|
|
7
|
+
Project-URL: Issues, https://github.com/mangybyte/leashbyte/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/mangybyte/leashbyte/blob/main/CHANGELOG.md
|
|
9
|
+
Author: MangyByte Ltd
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Requires-Python: <3.14,>=3.13
|
|
14
|
+
Requires-Dist: httpx<1,>=0.28
|
|
15
|
+
Requires-Dist: pydantic<3,>=2.11
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# LeashByte Python SDK
|
|
19
|
+
|
|
20
|
+
A Python client for the stable LeashByte REST API. The models are generated from `openapi.json`, and a hand-written client on top adds authentication, binary downloads and run polling. It needs Python 3.13.
|
|
21
|
+
|
|
22
|
+
Install it from PyPI:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install leashbyte-sdk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
With uv, use `uv add leashbyte-sdk`. From a checkout of the repository, `uv pip install ./sdk/python` installs the copy in your tree.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import os
|
|
32
|
+
|
|
33
|
+
from leashbyte_sdk import FetchRequest, LeashByteClient, RunCreateRequest
|
|
34
|
+
|
|
35
|
+
with LeashByteClient(api_key=os.environ["LEASHBYTE_API_KEY"]) as client:
|
|
36
|
+
page = client.fetch(FetchRequest(url="https://example.com"))
|
|
37
|
+
results = client.search("self-hosted web automation", limit=3)
|
|
38
|
+
run = client.create_run(
|
|
39
|
+
RunCreateRequest(
|
|
40
|
+
goal="Read the page title. Return it as the result.",
|
|
41
|
+
start_url="https://example.com",
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
finished = client.wait_for_run(run.id)
|
|
45
|
+
print(page.content)
|
|
46
|
+
print(results.results)
|
|
47
|
+
print(finished.state)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
You can leave out `api_key` and set `LEASHBYTE_API_KEY` or `LEASHBYTE_API_KEY_FILE` instead, which keeps the key out of your code. The default base URL is `http://127.0.0.1:8080`.
|
|
51
|
+
|
|
52
|
+
The client never logs keys, and its `repr` and API errors redact the configured one. Run artifacts and screenshots can contain page data, so keep them in private storage. For browser logins, use credential placeholders. Passwords don't belong in goals, URLs or ordinary text actions.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
leashbyte_sdk/__init__.py,sha256=kP4Hhr1C-VU2OKy3zB2_xRO_MdFOaj2XdaMEv0-6IWw,1235
|
|
2
|
+
leashbyte_sdk/_models.py,sha256=4wkEja0rSBLXwiE-LjvVFdDxQFFUAPsnmsFDO20oTHo,9836
|
|
3
|
+
leashbyte_sdk/client.py,sha256=K93bYAdCI_IhuZe3RvYuQHbh9lPu-Cd57Kwdy_ym4JY,12878
|
|
4
|
+
leashbyte_sdk-0.1.1.dist-info/METADATA,sha256=U2d_vt5jTyPKgVDWudknTDzjwOnEoG2D41UyL8fM_JA,2096
|
|
5
|
+
leashbyte_sdk-0.1.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
6
|
+
leashbyte_sdk-0.1.1.dist-info/licenses/LICENSE,sha256=vwNrEYRM8MZFqsqq2LhiQSj6822dhf-0SmMCSRCSDZc,11387
|
|
7
|
+
leashbyte_sdk-0.1.1.dist-info/licenses/NOTICE,sha256=MZAh6t_p5xC0de_MbU8cExuPceXxl0RMca7hz65iAbU,273
|
|
8
|
+
leashbyte_sdk-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright 2026 MangyByte Ltd
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright [yyyy] [name of copyright owner]
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
LeashByte Python SDK
|
|
2
|
+
Copyright 2026 MangyByte Ltd
|
|
3
|
+
|
|
4
|
+
This package uses HTTPX under BSD-3-Clause and Pydantic under MIT.
|
|
5
|
+
Those packages retain their licence files in their installed dist-info directories.
|
|
6
|
+
Neither locked dependency distribution contains a NOTICE file to copy.
|