stackshift 1.3.1__py3-none-any.whl → 1.8.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.
- stackshift/__init__.py +80 -0
- stackshift/agents.py +98 -0
- stackshift/client.py +35 -2
- stackshift/computers.py +902 -0
- stackshift/computers_adapters.py +353 -0
- stackshift/computers_transfer.py +557 -0
- stackshift/databases.py +226 -0
- stackshift/hosted_agents.py +78 -0
- stackshift/mail.py +6 -0
- stackshift/mail_agent_inboxes.py +199 -0
- stackshift/mail_agreements.py +158 -0
- stackshift/mail_events_webhooks.py +5 -1
- stackshift/mail_inbox_webhooks.py +89 -0
- stackshift/mail_team_inboxes.py +148 -0
- stackshift/partner.py +159 -1
- stackshift/teams.py +331 -0
- stackshift-1.8.0.dist-info/METADATA +716 -0
- {stackshift-1.3.1.dist-info → stackshift-1.8.0.dist-info}/RECORD +20 -9
- stackshift-1.3.1.dist-info/METADATA +0 -349
- {stackshift-1.3.1.dist-info → stackshift-1.8.0.dist-info}/WHEEL +0 -0
- {stackshift-1.3.1.dist-info → stackshift-1.8.0.dist-info}/top_level.txt +0 -0
stackshift/__init__.py
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
from .client import StackShift
|
|
2
|
+
from .agents import AgentConnectionOperationsClient, AgentConnectionsClient, AgentsClient
|
|
2
3
|
from .ai_credits import AICreditsClient
|
|
3
4
|
from .assets import ASSET_TRANSFORM_PRESETS, AssetsClient, asset_transform_options, asset_transform_spec, get_asset_transform_preset
|
|
5
|
+
from .computers import COMPUTER_CAPACITY_BUSY, COMPUTER_LIMIT_EXCEEDED, COMPUTER_SPEND_CAP_REACHED, Computer, ComputerActionError, ComputerCIClient, ComputerKeysClient, ComputersClient, ComputerSnapshotsClient, ComputerTransferError, ComputerWaitError, computer_public_pricing, exchange_computer_agent_claim, register_computer_agent, wait_for_computer_agent_key
|
|
6
|
+
from .computers_adapters import (
|
|
7
|
+
AnthropicComputerAdapter,
|
|
8
|
+
FunctionComputerAdapter,
|
|
9
|
+
GeminiComputerAdapter,
|
|
10
|
+
OpenAIComputerAdapter,
|
|
11
|
+
UnsupportedComputerAction,
|
|
12
|
+
COMPUTER_FUNCTION_TOOLS,
|
|
13
|
+
)
|
|
14
|
+
from .databases import DatabaseBranchesClient, DatabaseOperationFailed, DatabasesClient
|
|
15
|
+
from .hosted_agents import HostedAgentBudgetClient, HostedAgentSecretsClient, HostedAgentsClient
|
|
4
16
|
from .mail import (
|
|
5
17
|
MailClient,
|
|
6
18
|
MailDomainsClient,
|
|
@@ -13,6 +25,7 @@ from .mail_events_webhooks import MailEventsClient, MailWebhooksClient, verify_w
|
|
|
13
25
|
from .mail_streams import MailStreamsClient
|
|
14
26
|
from .mail_campaigns import MailAudiencesClient, MailCampaignsClient
|
|
15
27
|
from .mail_exports import MailExportsClient
|
|
28
|
+
from .mail_agreements import AgreementLimitsClient, AgreementsClient
|
|
16
29
|
from .mail_mailboxes import (
|
|
17
30
|
MailboxAliasesClient,
|
|
18
31
|
MailboxDomainsClient,
|
|
@@ -21,15 +34,65 @@ from .mail_mailboxes import (
|
|
|
21
34
|
MailboxesClient,
|
|
22
35
|
MailboxRoutesClient,
|
|
23
36
|
)
|
|
37
|
+
from .mail_agent_inboxes import AgentInboxesClient, AgentInboxMessagesClient
|
|
38
|
+
from .mail_team_inboxes import (
|
|
39
|
+
TeamInboxActivityClient,
|
|
40
|
+
TeamInboxConversationsClient,
|
|
41
|
+
TeamInboxesClient,
|
|
42
|
+
TeamInboxPendingRepliesClient,
|
|
43
|
+
TeamInboxSettingsClient,
|
|
44
|
+
)
|
|
45
|
+
from .mail_inbox_webhooks import (
|
|
46
|
+
INBOX_AGENT_INBOX_EVENT_TYPES,
|
|
47
|
+
INBOX_CONVERSATION_EVENT_TYPES,
|
|
48
|
+
INBOX_SENDING_EVENT_TYPES,
|
|
49
|
+
InboxAgentInboxEvent,
|
|
50
|
+
InboxConversationEvent,
|
|
51
|
+
InboxSendingEvent,
|
|
52
|
+
InboxWebhookEvent,
|
|
53
|
+
verify_inbox_webhook,
|
|
54
|
+
)
|
|
24
55
|
from .partner import PartnerClient
|
|
25
56
|
from .projects import ProjectsClient
|
|
57
|
+
from .teams import ComputerTeamsClient
|
|
26
58
|
from .workload_security import WorkloadSecurityClient
|
|
27
59
|
|
|
28
60
|
__all__ = [
|
|
29
61
|
"StackShift",
|
|
62
|
+
"COMPUTER_CAPACITY_BUSY",
|
|
63
|
+
"COMPUTER_LIMIT_EXCEEDED",
|
|
64
|
+
"COMPUTER_SPEND_CAP_REACHED",
|
|
65
|
+
"Computer",
|
|
66
|
+
"ComputerActionError",
|
|
67
|
+
"ComputerCIClient",
|
|
68
|
+
"computer_public_pricing",
|
|
69
|
+
"exchange_computer_agent_claim",
|
|
70
|
+
"register_computer_agent",
|
|
71
|
+
"wait_for_computer_agent_key",
|
|
72
|
+
"ComputerKeysClient",
|
|
73
|
+
"ComputersClient",
|
|
74
|
+
"ComputerSnapshotsClient",
|
|
75
|
+
"ComputerTeamsClient",
|
|
76
|
+
"ComputerTransferError",
|
|
77
|
+
"ComputerWaitError",
|
|
78
|
+
"AnthropicComputerAdapter",
|
|
79
|
+
"FunctionComputerAdapter",
|
|
80
|
+
"GeminiComputerAdapter",
|
|
81
|
+
"OpenAIComputerAdapter",
|
|
82
|
+
"UnsupportedComputerAction",
|
|
83
|
+
"COMPUTER_FUNCTION_TOOLS",
|
|
30
84
|
"AICreditsClient",
|
|
85
|
+
"AgentConnectionOperationsClient",
|
|
86
|
+
"AgentConnectionsClient",
|
|
87
|
+
"AgentsClient",
|
|
31
88
|
"ASSET_TRANSFORM_PRESETS",
|
|
32
89
|
"AssetsClient",
|
|
90
|
+
"DatabaseBranchesClient",
|
|
91
|
+
"DatabaseOperationFailed",
|
|
92
|
+
"DatabasesClient",
|
|
93
|
+
"HostedAgentBudgetClient",
|
|
94
|
+
"HostedAgentSecretsClient",
|
|
95
|
+
"HostedAgentsClient",
|
|
33
96
|
"MailClient",
|
|
34
97
|
"MailDomainsClient",
|
|
35
98
|
"MailEventsClient",
|
|
@@ -44,12 +107,29 @@ __all__ = [
|
|
|
44
107
|
"MailAudiencesClient",
|
|
45
108
|
"MailCampaignsClient",
|
|
46
109
|
"MailExportsClient",
|
|
110
|
+
"AgreementLimitsClient",
|
|
111
|
+
"AgreementsClient",
|
|
47
112
|
"MailboxAliasesClient",
|
|
48
113
|
"MailboxDomainsClient",
|
|
49
114
|
"MailboxGroupsClient",
|
|
50
115
|
"MailboxImportsClient",
|
|
51
116
|
"MailboxesClient",
|
|
52
117
|
"MailboxRoutesClient",
|
|
118
|
+
"AgentInboxesClient",
|
|
119
|
+
"AgentInboxMessagesClient",
|
|
120
|
+
"TeamInboxActivityClient",
|
|
121
|
+
"TeamInboxConversationsClient",
|
|
122
|
+
"TeamInboxesClient",
|
|
123
|
+
"TeamInboxPendingRepliesClient",
|
|
124
|
+
"TeamInboxSettingsClient",
|
|
125
|
+
"INBOX_AGENT_INBOX_EVENT_TYPES",
|
|
126
|
+
"INBOX_CONVERSATION_EVENT_TYPES",
|
|
127
|
+
"INBOX_SENDING_EVENT_TYPES",
|
|
128
|
+
"InboxAgentInboxEvent",
|
|
129
|
+
"InboxConversationEvent",
|
|
130
|
+
"InboxSendingEvent",
|
|
131
|
+
"InboxWebhookEvent",
|
|
132
|
+
"verify_inbox_webhook",
|
|
53
133
|
"PartnerClient",
|
|
54
134
|
"ProjectsClient",
|
|
55
135
|
"WorkloadSecurityClient",
|
stackshift/agents.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
from urllib.parse import quote
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _connection_data(payload: Any) -> Any:
|
|
8
|
+
if isinstance(payload, dict) and "data" in payload:
|
|
9
|
+
return payload["data"]
|
|
10
|
+
return payload
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _query(**values: Any) -> dict[str, Any] | None:
|
|
14
|
+
present = {key: value for key, value in values.items() if value is not None}
|
|
15
|
+
return present or None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AgentConnectionOperationsClient:
|
|
19
|
+
def __init__(self, client: Any) -> None:
|
|
20
|
+
self._client = client
|
|
21
|
+
|
|
22
|
+
def list(self, *, limit: int | None = None, cursor: str | None = None) -> dict[str, Any]:
|
|
23
|
+
return _connection_data(self._client.request("GET", "/agents/connections/operations", params=_query(limit=limit, cursor=cursor)))
|
|
24
|
+
|
|
25
|
+
def propose(
|
|
26
|
+
self,
|
|
27
|
+
*,
|
|
28
|
+
action: str,
|
|
29
|
+
configuration: dict[str, Any],
|
|
30
|
+
idempotency_key: str,
|
|
31
|
+
resource_id: str | None = None,
|
|
32
|
+
expected_resource_version: str | None = None,
|
|
33
|
+
reason: str | None = None,
|
|
34
|
+
) -> dict[str, Any]:
|
|
35
|
+
if not idempotency_key:
|
|
36
|
+
raise ValueError("Proposing an operation needs an idempotency_key. Keep it and send the same one when you retry.")
|
|
37
|
+
fields = {
|
|
38
|
+
"action": action, "resource_id": resource_id, "configuration": configuration,
|
|
39
|
+
"expected_resource_version": expected_resource_version, "reason": reason,
|
|
40
|
+
}
|
|
41
|
+
return _connection_data(self._client.request(
|
|
42
|
+
"POST", "/agents/connections/operations",
|
|
43
|
+
headers={"Idempotency-Key": idempotency_key},
|
|
44
|
+
json={key: value for key, value in fields.items() if value is not None},
|
|
45
|
+
))
|
|
46
|
+
|
|
47
|
+
def get(self, operation_id: str) -> dict[str, Any]:
|
|
48
|
+
return _connection_data(self._client.request("GET", f"/agents/connections/operations/{quote(operation_id, safe='')}"))
|
|
49
|
+
|
|
50
|
+
def wait(self, operation_id: str, *, timeout_seconds: int | None = None) -> dict[str, Any]:
|
|
51
|
+
return _connection_data(self._client.request(
|
|
52
|
+
"GET", f"/agents/connections/operations/{quote(operation_id, safe='')}/wait",
|
|
53
|
+
params=_query(timeout_seconds=timeout_seconds),
|
|
54
|
+
))
|
|
55
|
+
|
|
56
|
+
def approval(self, operation_id: str) -> dict[str, Any]:
|
|
57
|
+
return _connection_data(self._client.request("GET", f"/agents/connections/operations/{quote(operation_id, safe='')}/approval"))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class AgentConnectionsClient:
|
|
61
|
+
def __init__(self, client: Any) -> None:
|
|
62
|
+
self._client = client
|
|
63
|
+
self.operations = AgentConnectionOperationsClient(client)
|
|
64
|
+
|
|
65
|
+
def identity(self) -> dict[str, Any]:
|
|
66
|
+
return _connection_data(self._client.request("GET", "/agents/connections/identity"))
|
|
67
|
+
|
|
68
|
+
def resources(
|
|
69
|
+
self, *, kind: str | None = None, query: str | None = None, limit: int | None = None, cursor: str | None = None,
|
|
70
|
+
) -> dict[str, Any]:
|
|
71
|
+
return _connection_data(self._client.request(
|
|
72
|
+
"GET", "/agents/connections/resources",
|
|
73
|
+
params=_query(kind=kind, query=query, limit=limit, cursor=cursor),
|
|
74
|
+
))
|
|
75
|
+
|
|
76
|
+
def capabilities(self, *, family: str | None = None) -> list[dict[str, Any]]:
|
|
77
|
+
return _connection_data(self._client.request("GET", "/agents/connections/capabilities", params=_query(family=family)))
|
|
78
|
+
|
|
79
|
+
def plan(self) -> dict[str, Any]:
|
|
80
|
+
return _connection_data(self._client.request("GET", "/agents/connections/plan"))
|
|
81
|
+
|
|
82
|
+
def task_facts(self, objective_id: str) -> dict[str, Any]:
|
|
83
|
+
return _connection_data(self._client.request("GET", "/agents/connections/task-facts", params={"objective_id": objective_id}))
|
|
84
|
+
|
|
85
|
+
def history(self, *, limit: int | None = None, cursor: str | None = None) -> dict[str, Any]:
|
|
86
|
+
return _connection_data(self._client.request("GET", "/agents/connections/history", params=_query(limit=limit, cursor=cursor)))
|
|
87
|
+
|
|
88
|
+
def lower_level(self, *, level: str, expected_version: int | None = None) -> dict[str, Any]:
|
|
89
|
+
fields = {"level": level, "expected_version": expected_version}
|
|
90
|
+
return _connection_data(self._client.request(
|
|
91
|
+
"PUT", "/agents/connections/level",
|
|
92
|
+
json={key: value for key, value in fields.items() if value is not None},
|
|
93
|
+
))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AgentsClient:
|
|
97
|
+
def __init__(self, client: Any) -> None:
|
|
98
|
+
self.connections = AgentConnectionsClient(client)
|
stackshift/client.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
import re
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
6
7
|
import requests
|
|
@@ -26,16 +27,27 @@ class StackShift:
|
|
|
26
27
|
self.cdn_base_url = cdn_base_url.rstrip("/")
|
|
27
28
|
self.session = session or requests.Session()
|
|
28
29
|
|
|
30
|
+
from .agents import AgentsClient
|
|
29
31
|
from .ai_credits import AICreditsClient
|
|
30
32
|
from .assets import AssetsClient
|
|
33
|
+
from .computers import ComputersClient
|
|
34
|
+
from .databases import DatabasesClient
|
|
35
|
+
from .hosted_agents import HostedAgentsClient
|
|
31
36
|
from .mail import MailClient
|
|
32
37
|
from .partner import PartnerClient
|
|
33
38
|
from .projects import ProjectsClient
|
|
39
|
+
from .teams import ComputerTeamsClient
|
|
34
40
|
from .workload_security import WorkloadSecurityClient
|
|
35
41
|
|
|
42
|
+
self.agents = AgentsClient(self)
|
|
36
43
|
self.ai_credits = AICreditsClient(self)
|
|
37
44
|
self.projects = ProjectsClient(self)
|
|
38
45
|
self.assets = AssetsClient(self)
|
|
46
|
+
self.computers = ComputersClient(self)
|
|
47
|
+
self.computers.teams = ComputerTeamsClient(self)
|
|
48
|
+
self.teams = self.computers.teams
|
|
49
|
+
self.databases = DatabasesClient(self)
|
|
50
|
+
self.hosted_agents = HostedAgentsClient(self)
|
|
39
51
|
self.mail = MailClient(self)
|
|
40
52
|
self.partner = PartnerClient(self)
|
|
41
53
|
self.workload_security = WorkloadSecurityClient(self)
|
|
@@ -57,19 +69,40 @@ class StackShift:
|
|
|
57
69
|
error = payload.get("error") if isinstance(payload, dict) else None
|
|
58
70
|
if isinstance(error, dict):
|
|
59
71
|
raise StackShiftAPIError(
|
|
60
|
-
error.get("message") or f"StackShift API request failed with {response.status_code}",
|
|
72
|
+
error.get("message") or payload.get("message") or f"StackShift API request failed with {response.status_code}",
|
|
61
73
|
status_code=response.status_code,
|
|
62
74
|
code=error.get("code"),
|
|
63
75
|
details=error.get("details"),
|
|
64
76
|
)
|
|
65
77
|
message = payload.get("message") if isinstance(payload, dict) else None
|
|
66
|
-
raise StackShiftAPIError(
|
|
78
|
+
raise StackShiftAPIError(
|
|
79
|
+
message or f"StackShift API request failed with {response.status_code}",
|
|
80
|
+
status_code=response.status_code,
|
|
81
|
+
code=_top_level_error_code(payload),
|
|
82
|
+
details=_top_level_error_details(payload),
|
|
83
|
+
)
|
|
67
84
|
|
|
68
85
|
if isinstance(payload, dict) and "success" in payload and "data" in payload:
|
|
69
86
|
return payload["data"]
|
|
70
87
|
return payload
|
|
71
88
|
|
|
72
89
|
|
|
90
|
+
def _top_level_error_code(payload: Any) -> str | None:
|
|
91
|
+
if not isinstance(payload, dict):
|
|
92
|
+
return None
|
|
93
|
+
if isinstance(payload.get("code"), str):
|
|
94
|
+
return payload["code"]
|
|
95
|
+
error = payload.get("error")
|
|
96
|
+
return error if isinstance(error, str) and re.fullmatch(r"[a-z][a-z0-9_]*", error) else None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _top_level_error_details(payload: Any) -> dict[str, Any] | None:
|
|
100
|
+
if not isinstance(payload, dict):
|
|
101
|
+
return None
|
|
102
|
+
details = {key: value for key, value in payload.items() if key not in ("success", "status", "status_code", "message", "error", "code")}
|
|
103
|
+
return details or None
|
|
104
|
+
|
|
105
|
+
|
|
73
106
|
class StackShiftAPIError(RuntimeError):
|
|
74
107
|
def __init__(
|
|
75
108
|
self,
|