pi-agent-python-sdk 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.
- pi_agent/__init__.py +47 -0
- pi_agent/_events.py +108 -0
- pi_agent/_launch.py +203 -0
- pi_agent/_runs.py +317 -0
- pi_agent/_transport.py +360 -0
- pi_agent/_usage.py +88 -0
- pi_agent/client.py +796 -0
- pi_agent/errors.py +87 -0
- pi_agent/py.typed +0 -0
- pi_agent/sync.py +684 -0
- pi_agent/types.py +960 -0
- pi_agent_python_sdk-0.1.0.dist-info/METADATA +231 -0
- pi_agent_python_sdk-0.1.0.dist-info/RECORD +15 -0
- pi_agent_python_sdk-0.1.0.dist-info/WHEEL +4 -0
- pi_agent_python_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
pi_agent/errors.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Failures reported by the client; no exception automatically dumps wire payloads."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from .types import RunResult
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PiError(Exception):
|
|
12
|
+
"""Base class for client and Pi protocol failures."""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PiCommandError(PiError):
|
|
16
|
+
"""Pi rejected a command. The original error is available explicitly."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, command: str, error: str, request_id: str | None = None) -> None:
|
|
19
|
+
self.command = command
|
|
20
|
+
self.error = error
|
|
21
|
+
self.request_id = request_id
|
|
22
|
+
# Extension errors can contain prompt text or provider diagnostics.
|
|
23
|
+
super().__init__(f"Pi rejected command {command!r}; inspect .error for details")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class PiProtocolError(PiError):
|
|
27
|
+
"""The child emitted invalid framing or a malformed protocol envelope."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PiProcessError(PiError):
|
|
31
|
+
"""The owned process could not start or closed unexpectedly."""
|
|
32
|
+
|
|
33
|
+
def __init__(self, message: str, returncode: int | None = None) -> None:
|
|
34
|
+
self.returncode = returncode
|
|
35
|
+
super().__init__(message)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class PiTimeoutError(PiError, TimeoutError):
|
|
39
|
+
"""A deadline elapsed; an uncertain operation may still have taken effect."""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
message: str,
|
|
44
|
+
command: str | None = None,
|
|
45
|
+
request_id: str | None = None,
|
|
46
|
+
uncertain: bool = True,
|
|
47
|
+
) -> None:
|
|
48
|
+
self.command = command
|
|
49
|
+
self.request_id = request_id
|
|
50
|
+
self.uncertain = uncertain
|
|
51
|
+
super().__init__(message)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class PiRunStartTimeout(PiTimeoutError):
|
|
55
|
+
"""An accepted prompt did not produce an observed run before its deadline."""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class PiBusyError(PiError):
|
|
59
|
+
"""The operation conflicts with an active owned run or stream consumer."""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class PiSubscriptionOverflow(PiError):
|
|
63
|
+
"""A subscriber exceeded its configured event buffer."""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class PiResultOverflow(PiError):
|
|
67
|
+
"""An owned run exceeded its independent retained-result capacity."""
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class PiRunOwnershipError(PiBusyError):
|
|
71
|
+
"""Prior low-level work prevents reliable attribution of a new owned run."""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class PiUIHandlerError(PiError):
|
|
75
|
+
"""An extension UI callback failed."""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class PiRunError(PiError):
|
|
79
|
+
"""A settled run ended in error or abortion; .result preserves partial work."""
|
|
80
|
+
|
|
81
|
+
def __init__(self, message: str, result: RunResult) -> None:
|
|
82
|
+
self.result = result
|
|
83
|
+
super().__init__(message)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class PiVersionError(PiError):
|
|
87
|
+
"""The selected Pi version does not meet the requested compatibility policy."""
|
pi_agent/py.typed
ADDED
|
File without changes
|