xiii-cli-core 0.1.0__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.
- xiii_cli_core/__init__.py +1 -0
- xiii_cli_core/client.py +568 -0
- xiii_cli_core/config.py +527 -0
- xiii_cli_core/describe.py +196 -0
- xiii_cli_core/direct.py +1158 -0
- xiii_cli_core/errors.py +103 -0
- xiii_cli_core/main.py +732 -0
- xiii_cli_core/oauth.py +750 -0
- xiii_cli_core/openapi.py +643 -0
- xiii_cli_core/py.typed +0 -0
- xiii_cli_core/render.py +44 -0
- xiii_cli_core/skill.py +89 -0
- xiii_cli_core/thread.py +230 -0
- xiii_cli_core/tokens.py +115 -0
- xiii_cli_core-0.1.0.dist-info/METADATA +86 -0
- xiii_cli_core-0.1.0.dist-info/RECORD +18 -0
- xiii_cli_core-0.1.0.dist-info/WHEEL +4 -0
- xiii_cli_core-0.1.0.dist-info/licenses/LICENSE +202 -0
xiii_cli_core/errors.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CliError(Exception):
|
|
5
|
+
"""A failure the CLI reports instead of a traceback.
|
|
6
|
+
|
|
7
|
+
`code` is the server's error code (`MAIL_ACCOUNT_NOT_FOUND`), `detail` the
|
|
8
|
+
server's redacted `detail` as JSON, so a script branches on either without
|
|
9
|
+
parsing the message.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
error_type = "runtime_error"
|
|
13
|
+
exit_code = 1
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
message: str,
|
|
18
|
+
*,
|
|
19
|
+
status_code: int | None = None,
|
|
20
|
+
code: str | None = None,
|
|
21
|
+
detail: Any = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
super().__init__(message)
|
|
24
|
+
self.status_code = status_code
|
|
25
|
+
self.code = code
|
|
26
|
+
self.detail = detail
|
|
27
|
+
|
|
28
|
+
def as_payload(self) -> dict[str, object]:
|
|
29
|
+
payload: dict[str, object] = {
|
|
30
|
+
"error": self.error_type,
|
|
31
|
+
"message": str(self),
|
|
32
|
+
"exit_code": self.exit_code,
|
|
33
|
+
}
|
|
34
|
+
if self.status_code is not None:
|
|
35
|
+
payload["status_code"] = self.status_code
|
|
36
|
+
if self.code is not None:
|
|
37
|
+
payload["code"] = self.code
|
|
38
|
+
if self.detail is not None:
|
|
39
|
+
payload["detail"] = self.detail
|
|
40
|
+
return payload
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ConfigurationError(CliError):
|
|
44
|
+
error_type = "configuration_error"
|
|
45
|
+
exit_code = 2
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AuthenticationError(CliError):
|
|
49
|
+
error_type = "authentication_error"
|
|
50
|
+
exit_code = 3
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class AuthorizationError(CliError):
|
|
54
|
+
error_type = "authorization_error"
|
|
55
|
+
exit_code = 4
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ApiError(CliError):
|
|
59
|
+
error_type = "api_error"
|
|
60
|
+
exit_code = 5
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class RateLimitError(ApiError):
|
|
64
|
+
"""A 429 that outlasted the retries; `retry_after` is the server's pause."""
|
|
65
|
+
|
|
66
|
+
error_type = "rate_limit_error"
|
|
67
|
+
exit_code = 11
|
|
68
|
+
|
|
69
|
+
def __init__(
|
|
70
|
+
self, message: str, *, retry_after: float | None = None, **fields: Any
|
|
71
|
+
) -> None:
|
|
72
|
+
super().__init__(message, **fields)
|
|
73
|
+
self.retry_after = retry_after
|
|
74
|
+
|
|
75
|
+
def as_payload(self) -> dict[str, object]:
|
|
76
|
+
payload = super().as_payload()
|
|
77
|
+
if self.retry_after is not None:
|
|
78
|
+
payload["retry_after"] = self.retry_after
|
|
79
|
+
return payload
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class ThreadProtocolError(CliError):
|
|
83
|
+
error_type = "thread_protocol_error"
|
|
84
|
+
exit_code = 7
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ThreadExpectationError(CliError):
|
|
88
|
+
error_type = "thread_expectation_error"
|
|
89
|
+
exit_code = 8
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class UsageError(CliError):
|
|
93
|
+
"""The command line itself did not parse: unknown option, missing argument."""
|
|
94
|
+
|
|
95
|
+
error_type = "usage_error"
|
|
96
|
+
exit_code = 9
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class NetworkError(CliError):
|
|
100
|
+
"""The API could not be reached or the connection broke off."""
|
|
101
|
+
|
|
102
|
+
error_type = "network_error"
|
|
103
|
+
exit_code = 10
|