stackshift 1.8.0__py3-none-any.whl → 1.10.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 +6 -1
- stackshift/assets.py +2 -2
- stackshift/assets_transforms.py +56 -0
- stackshift/client.py +2 -0
- stackshift/computers.py +61 -4
- stackshift/events.py +181 -0
- {stackshift-1.8.0.dist-info → stackshift-1.10.0.dist-info}/METADATA +39 -1
- {stackshift-1.8.0.dist-info → stackshift-1.10.0.dist-info}/RECORD +10 -9
- stackshift/assets_workflows.py +0 -184
- {stackshift-1.8.0.dist-info → stackshift-1.10.0.dist-info}/WHEEL +0 -0
- {stackshift-1.8.0.dist-info → stackshift-1.10.0.dist-info}/top_level.txt +0 -0
stackshift/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@ from .client import StackShift
|
|
|
2
2
|
from .agents import AgentConnectionOperationsClient, AgentConnectionsClient, AgentsClient
|
|
3
3
|
from .ai_credits import AICreditsClient
|
|
4
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
|
|
5
|
+
from .computers import COMPUTER_AGENT_PROVIDERS, 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
6
|
from .computers_adapters import (
|
|
7
7
|
AnthropicComputerAdapter,
|
|
8
8
|
FunctionComputerAdapter,
|
|
@@ -12,6 +12,7 @@ from .computers_adapters import (
|
|
|
12
12
|
COMPUTER_FUNCTION_TOOLS,
|
|
13
13
|
)
|
|
14
14
|
from .databases import DatabaseBranchesClient, DatabaseOperationFailed, DatabasesClient
|
|
15
|
+
from .events import EventSignatureError, EventsClient, verify_event
|
|
15
16
|
from .hosted_agents import HostedAgentBudgetClient, HostedAgentSecretsClient, HostedAgentsClient
|
|
16
17
|
from .mail import (
|
|
17
18
|
MailClient,
|
|
@@ -59,6 +60,7 @@ from .workload_security import WorkloadSecurityClient
|
|
|
59
60
|
|
|
60
61
|
__all__ = [
|
|
61
62
|
"StackShift",
|
|
63
|
+
"COMPUTER_AGENT_PROVIDERS",
|
|
62
64
|
"COMPUTER_CAPACITY_BUSY",
|
|
63
65
|
"COMPUTER_LIMIT_EXCEEDED",
|
|
64
66
|
"COMPUTER_SPEND_CAP_REACHED",
|
|
@@ -137,6 +139,9 @@ __all__ = [
|
|
|
137
139
|
"asset_transform_spec",
|
|
138
140
|
"get_asset_transform_preset",
|
|
139
141
|
"verify_webhook_signature",
|
|
142
|
+
"EventSignatureError",
|
|
143
|
+
"EventsClient",
|
|
144
|
+
"verify_event",
|
|
140
145
|
]
|
|
141
146
|
|
|
142
147
|
from .support_actions import (ActionProtocolError, sign_action, verify_action, verify_receipt, encode_receipt)
|
stackshift/assets.py
CHANGED
|
@@ -6,7 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
from typing import Any, BinaryIO
|
|
7
7
|
from urllib.parse import quote
|
|
8
8
|
|
|
9
|
-
from .
|
|
9
|
+
from .assets_transforms import AssetTransformsMixin
|
|
10
10
|
from .assets_dam import AssetDAMClient
|
|
11
11
|
from .assets_video import AssetVideoClient
|
|
12
12
|
from .assets_platform import AssetPlatformClient
|
|
@@ -52,7 +52,7 @@ def asset_transform_spec(**options: Any) -> str:
|
|
|
52
52
|
return _transform_spec(options)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class AssetsClient(
|
|
55
|
+
class AssetsClient(AssetTransformsMixin):
|
|
56
56
|
def __init__(self, client: Any) -> None:
|
|
57
57
|
self._client = client
|
|
58
58
|
self.dam = AssetDAMClient(client)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
from urllib.parse import quote
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AssetTransformsMixin:
|
|
8
|
+
"""Typed route helpers for deterministic media transforms and generation."""
|
|
9
|
+
|
|
10
|
+
_client: Any
|
|
11
|
+
|
|
12
|
+
def create_transformation_v2(
|
|
13
|
+
self, name: str, definition: dict[str, Any], *, eager: bool = False
|
|
14
|
+
) -> dict[str, Any]:
|
|
15
|
+
return self._client.request(
|
|
16
|
+
"POST", "/assets/transformations",
|
|
17
|
+
json={"name": name, "definition": definition, "eager": eager},
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def estimate_transform(
|
|
21
|
+
self, asset_id: str, version_id: str, definition: dict[str, Any]
|
|
22
|
+
) -> dict[str, Any]:
|
|
23
|
+
return self._client.request(
|
|
24
|
+
"POST", f"/assets/{quote(asset_id, safe='')}/transforms/estimate",
|
|
25
|
+
json={"version_id": version_id, "definition": definition},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def materialize_transform(
|
|
29
|
+
self,
|
|
30
|
+
asset_id: str,
|
|
31
|
+
*,
|
|
32
|
+
definition: dict[str, Any] | None = None,
|
|
33
|
+
preset: str | None = None,
|
|
34
|
+
idempotency_key: str | None = None,
|
|
35
|
+
) -> dict[str, Any]:
|
|
36
|
+
payload = {key: value for key, value in {
|
|
37
|
+
"definition": definition, "preset": preset,
|
|
38
|
+
}.items() if value not in (None, "")}
|
|
39
|
+
headers = {"Idempotency-Key": idempotency_key} if idempotency_key else None
|
|
40
|
+
return self._client.request(
|
|
41
|
+
"POST", f"/assets/{quote(asset_id, safe='')}/transforms", json=payload, headers=headers
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def derivatives(self, asset_id: str) -> dict[str, Any]:
|
|
45
|
+
return self._client.request("GET", f"/assets/{quote(asset_id, safe='')}/derivatives")
|
|
46
|
+
|
|
47
|
+
def generate(
|
|
48
|
+
self, payload: dict[str, Any], *, idempotency_key: str
|
|
49
|
+
) -> dict[str, Any]:
|
|
50
|
+
return self._client.request(
|
|
51
|
+
"POST", "/assets/generations", json=payload,
|
|
52
|
+
headers={"Idempotency-Key": idempotency_key},
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def automation(self) -> dict[str, Any]:
|
|
56
|
+
return self._client.request("GET", "/assets/automation")
|
stackshift/client.py
CHANGED
|
@@ -32,6 +32,7 @@ class StackShift:
|
|
|
32
32
|
from .assets import AssetsClient
|
|
33
33
|
from .computers import ComputersClient
|
|
34
34
|
from .databases import DatabasesClient
|
|
35
|
+
from .events import EventsClient
|
|
35
36
|
from .hosted_agents import HostedAgentsClient
|
|
36
37
|
from .mail import MailClient
|
|
37
38
|
from .partner import PartnerClient
|
|
@@ -47,6 +48,7 @@ class StackShift:
|
|
|
47
48
|
self.computers.teams = ComputerTeamsClient(self)
|
|
48
49
|
self.teams = self.computers.teams
|
|
49
50
|
self.databases = DatabasesClient(self)
|
|
51
|
+
self.events = EventsClient(self)
|
|
50
52
|
self.hosted_agents = HostedAgentsClient(self)
|
|
51
53
|
self.mail = MailClient(self)
|
|
52
54
|
self.partner = PartnerClient(self)
|
stackshift/computers.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
+
import os
|
|
4
5
|
import time
|
|
5
6
|
import uuid
|
|
6
7
|
from typing import Any, Iterator
|
|
@@ -16,6 +17,8 @@ COMPUTER_LIMIT_EXCEEDED = "limit_exceeded"
|
|
|
16
17
|
COMPUTER_CAPACITY_BUSY = "capacity_busy"
|
|
17
18
|
COMPUTER_SPEND_CAP_REACHED = "spend_cap_reached"
|
|
18
19
|
|
|
20
|
+
COMPUTER_AGENT_PROVIDERS = ("claude", "codex", "gemini", "opencode", "cursor", "copilot", "amp", "qwen")
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
class ComputerWaitError(RuntimeError):
|
|
21
24
|
def __init__(self, message: str, computer: dict[str, Any] | None = None) -> None:
|
|
@@ -193,6 +196,9 @@ class ComputersClient:
|
|
|
193
196
|
self.snapshots = ComputerSnapshotsClient(client)
|
|
194
197
|
self.ci = ComputerCIClient(client)
|
|
195
198
|
|
|
199
|
+
def ensure_project(self) -> dict[str, Any]:
|
|
200
|
+
return self._client.request("POST", "/computers/project")
|
|
201
|
+
|
|
196
202
|
def templates(self, project_id: str) -> list[dict[str, Any]]:
|
|
197
203
|
return self._client.request("GET", "/computers/templates", params={"project_id": project_id})
|
|
198
204
|
|
|
@@ -367,9 +373,36 @@ class ComputersClient:
|
|
|
367
373
|
def ssh_certificate(self, computer_id: str, public_key: str) -> dict[str, Any]:
|
|
368
374
|
return self._client.request("POST", "/computers/ssh/certificates", json={"computer_id": computer_id, "public_key": public_key})
|
|
369
375
|
|
|
370
|
-
def prompt_agent(self, computer_id: str, prompt: str, *, conversation_id: str | None = None, provider: str | None = None, model: str | None = None, cwd: str | None = None, env: dict[str, str] | None = None, secret_binding_ids: list[str] | None = None) -> dict[str, Any]:
|
|
371
|
-
|
|
372
|
-
|
|
376
|
+
def prompt_agent(self, computer_id: str, prompt: str | None = None, *, conversation_id: str | None = None, provider: str | None = None, model: str | None = None, cwd: str | None = None, env: dict[str, str] | None = None, secret_binding_ids: list[str] | None = None, attachments: list[str] | None = None, forks: int | None = None, prompts: list[str] | None = None) -> dict[str, Any]:
|
|
377
|
+
"""Send a prompt. Returns a conversation, or a fan-out when `forks` or `prompts` is set."""
|
|
378
|
+
optional = {"prompt": prompt, "conversation_id": conversation_id, "provider": provider, "model": model, "cwd": cwd, "env": env, "secret_binding_ids": secret_binding_ids, "attachments": attachments, "forks": forks, "prompts": prompts}
|
|
379
|
+
return self._client.request("POST", f"/computers/{_seg(computer_id)}/agent/prompt", json={key: value for key, value in optional.items() if value is not None})
|
|
380
|
+
|
|
381
|
+
def attach_agent_file(self, computer_id: str, local_path: str) -> str:
|
|
382
|
+
remote = f"/workspace/.stackshift/attachments/{uuid.uuid4().hex}/{os.path.basename(local_path)}"
|
|
383
|
+
self.upload(computer_id, local_path, remote)
|
|
384
|
+
return remote
|
|
385
|
+
|
|
386
|
+
def agent_providers(self, computer_id: str, *, refresh: bool = False) -> list[dict[str, Any]]:
|
|
387
|
+
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/providers", params=_params(refresh="1" if refresh else None))["providers"]
|
|
388
|
+
|
|
389
|
+
def agent_models(self, computer_id: str, *, provider: str | None = None, secret_binding_id: str | None = None) -> dict[str, Any]:
|
|
390
|
+
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/models", params=_params(provider=provider, secret_binding_id=secret_binding_id))
|
|
391
|
+
|
|
392
|
+
def agent_result(self, computer_id: str, conversation_id: str, *, wait: bool = False) -> dict[str, Any]:
|
|
393
|
+
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/conversations/{_seg(conversation_id)}/result", params=_params(wait="1" if wait else None))
|
|
394
|
+
|
|
395
|
+
def agent_turns(self, computer_id: str, *, limit: int | None = None) -> list[dict[str, Any]]:
|
|
396
|
+
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/turns", params=_params(limit=limit))["turns"]
|
|
397
|
+
|
|
398
|
+
def agent_fanouts(self, computer_id: str) -> list[dict[str, Any]]:
|
|
399
|
+
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/fanouts")["fanouts"]
|
|
400
|
+
|
|
401
|
+
def agent_fanout(self, computer_id: str, fanout_id: str) -> dict[str, Any]:
|
|
402
|
+
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/fanouts/{_seg(fanout_id)}")
|
|
403
|
+
|
|
404
|
+
def keep_agent_fork(self, computer_id: str, fanout_id: str, fork_computer_id: str) -> dict[str, Any]:
|
|
405
|
+
return self._client.request("POST", f"/computers/{_seg(computer_id)}/agent/fanouts/{_seg(fanout_id)}/keep", json={"computer_id": fork_computer_id})
|
|
373
406
|
|
|
374
407
|
def agent_conversations(self, computer_id: str) -> list[dict[str, Any]]:
|
|
375
408
|
return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/conversations")["conversations"]
|
|
@@ -835,9 +868,33 @@ class Computer:
|
|
|
835
868
|
def revoke_ssh_tokens(self) -> None:
|
|
836
869
|
self._client.revoke_ssh_tokens(self.id)
|
|
837
870
|
|
|
838
|
-
def prompt_agent(self, prompt: str, **options: Any) -> dict[str, Any]:
|
|
871
|
+
def prompt_agent(self, prompt: str | None = None, **options: Any) -> dict[str, Any]:
|
|
839
872
|
return self._client.prompt_agent(self.id, prompt, **options)
|
|
840
873
|
|
|
874
|
+
def attach_agent_file(self, local_path: str) -> str:
|
|
875
|
+
return self._client.attach_agent_file(self.id, local_path)
|
|
876
|
+
|
|
877
|
+
def agent_providers(self, *, refresh: bool = False) -> list[dict[str, Any]]:
|
|
878
|
+
return self._client.agent_providers(self.id, refresh=refresh)
|
|
879
|
+
|
|
880
|
+
def agent_models(self, *, provider: str | None = None, secret_binding_id: str | None = None) -> dict[str, Any]:
|
|
881
|
+
return self._client.agent_models(self.id, provider=provider, secret_binding_id=secret_binding_id)
|
|
882
|
+
|
|
883
|
+
def agent_result(self, conversation_id: str, *, wait: bool = False) -> dict[str, Any]:
|
|
884
|
+
return self._client.agent_result(self.id, conversation_id, wait=wait)
|
|
885
|
+
|
|
886
|
+
def agent_turns(self, *, limit: int | None = None) -> list[dict[str, Any]]:
|
|
887
|
+
return self._client.agent_turns(self.id, limit=limit)
|
|
888
|
+
|
|
889
|
+
def agent_fanouts(self) -> list[dict[str, Any]]:
|
|
890
|
+
return self._client.agent_fanouts(self.id)
|
|
891
|
+
|
|
892
|
+
def agent_fanout(self, fanout_id: str) -> dict[str, Any]:
|
|
893
|
+
return self._client.agent_fanout(self.id, fanout_id)
|
|
894
|
+
|
|
895
|
+
def keep_agent_fork(self, fanout_id: str, fork_computer_id: str) -> dict[str, Any]:
|
|
896
|
+
return self._client.keep_agent_fork(self.id, fanout_id, fork_computer_id)
|
|
897
|
+
|
|
841
898
|
def agent_conversations(self) -> list[dict[str, Any]]:
|
|
842
899
|
return self._client.agent_conversations(self.id)
|
|
843
900
|
|
stackshift/events.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import time
|
|
5
|
+
from typing import Any
|
|
6
|
+
from urllib.parse import quote
|
|
7
|
+
|
|
8
|
+
from .mail_events_webhooks import verify_webhook_signature
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EventSignatureError(ValueError):
|
|
12
|
+
def __init__(self, code: str, message: str) -> None:
|
|
13
|
+
super().__init__(message)
|
|
14
|
+
self.code = code
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def verify_event(
|
|
18
|
+
*,
|
|
19
|
+
raw_body: bytes | str,
|
|
20
|
+
signature_header: str | None,
|
|
21
|
+
secret: str,
|
|
22
|
+
tolerance_seconds: int = 300,
|
|
23
|
+
timestamp: int | None = None,
|
|
24
|
+
now: int | None = None,
|
|
25
|
+
) -> dict[str, Any]:
|
|
26
|
+
if not signature_header:
|
|
27
|
+
raise EventSignatureError("missing_signature", "The StackShift-Signature header is missing.")
|
|
28
|
+
signed_at = timestamp if timestamp is not None else _signed_timestamp(signature_header)
|
|
29
|
+
if signed_at is None:
|
|
30
|
+
raise EventSignatureError("invalid_signature", "The StackShift-Signature header has no timestamp.")
|
|
31
|
+
matches = verify_webhook_signature(
|
|
32
|
+
raw_body=raw_body,
|
|
33
|
+
signature_header=signature_header,
|
|
34
|
+
timestamp_header=str(signed_at),
|
|
35
|
+
secret=secret,
|
|
36
|
+
tolerance_seconds=2**62,
|
|
37
|
+
)
|
|
38
|
+
if not matches:
|
|
39
|
+
raise EventSignatureError("invalid_signature", "The StackShift-Signature header does not match the body.")
|
|
40
|
+
current = int(time.time()) if now is None else int(now)
|
|
41
|
+
if tolerance_seconds > 0 and abs(current - signed_at) > tolerance_seconds:
|
|
42
|
+
raise EventSignatureError("expired", "The StackShift-Signature timestamp is outside the allowed tolerance.")
|
|
43
|
+
try:
|
|
44
|
+
return json.loads(raw_body)
|
|
45
|
+
except ValueError as error:
|
|
46
|
+
raise EventSignatureError("invalid_body", "The event body is not valid JSON.") from error
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _signed_timestamp(header: str) -> int | None:
|
|
50
|
+
for part in header.split(","):
|
|
51
|
+
key, _, value = part.strip().partition("=")
|
|
52
|
+
if key == "t":
|
|
53
|
+
try:
|
|
54
|
+
return int(value)
|
|
55
|
+
except ValueError:
|
|
56
|
+
return None
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _clean(params: dict[str, Any]) -> dict[str, Any]:
|
|
61
|
+
return {key: value for key, value in params.items() if value not in (None, "")}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _id(value: str) -> str:
|
|
65
|
+
return quote(value, safe="")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class EventsClient:
|
|
69
|
+
def __init__(self, client: Any) -> None:
|
|
70
|
+
self._client = client
|
|
71
|
+
|
|
72
|
+
def verify(
|
|
73
|
+
self,
|
|
74
|
+
*,
|
|
75
|
+
raw_body: bytes | str,
|
|
76
|
+
signature_header: str | None,
|
|
77
|
+
secret: str,
|
|
78
|
+
tolerance_seconds: int = 300,
|
|
79
|
+
timestamp: int | None = None,
|
|
80
|
+
now: int | None = None,
|
|
81
|
+
) -> dict[str, Any]:
|
|
82
|
+
return verify_event(
|
|
83
|
+
raw_body=raw_body,
|
|
84
|
+
signature_header=signature_header,
|
|
85
|
+
secret=secret,
|
|
86
|
+
tolerance_seconds=tolerance_seconds,
|
|
87
|
+
timestamp=timestamp,
|
|
88
|
+
now=now,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def catalog(self) -> dict[str, Any]:
|
|
92
|
+
return self._client.request("GET", "/events/catalog")
|
|
93
|
+
|
|
94
|
+
def list(
|
|
95
|
+
self,
|
|
96
|
+
*,
|
|
97
|
+
type: str | None = None,
|
|
98
|
+
product: str | None = None,
|
|
99
|
+
project_id: str | None = None,
|
|
100
|
+
since: str | None = None,
|
|
101
|
+
cursor: str | None = None,
|
|
102
|
+
limit: int | None = None,
|
|
103
|
+
team_id: str | None = None,
|
|
104
|
+
) -> dict[str, Any]:
|
|
105
|
+
params = _clean({"type": type, "product": product, "project_id": project_id, "since": since, "cursor": cursor, "limit": limit, "team_id": team_id})
|
|
106
|
+
return self._client.request("GET", "/events", params=params)
|
|
107
|
+
|
|
108
|
+
def get(self, event_id: str) -> dict[str, Any]:
|
|
109
|
+
return self._client.request("GET", f"/events/{_id(event_id)}")
|
|
110
|
+
|
|
111
|
+
def create_subscription(self, **body: Any) -> dict[str, Any]:
|
|
112
|
+
return self._client.request("POST", "/events/subscriptions", json=_clean(body))
|
|
113
|
+
|
|
114
|
+
def list_subscriptions(self, *, team_id: str | None = None, project_id: str | None = None) -> dict[str, Any]:
|
|
115
|
+
return self._client.request("GET", "/events/subscriptions", params=_clean({"team_id": team_id, "project_id": project_id}))
|
|
116
|
+
|
|
117
|
+
def get_subscription(self, subscription_id: str) -> dict[str, Any]:
|
|
118
|
+
return self._client.request("GET", f"/events/subscriptions/{_id(subscription_id)}")
|
|
119
|
+
|
|
120
|
+
def update_subscription(self, subscription_id: str, **body: Any) -> dict[str, Any]:
|
|
121
|
+
return self._client.request("PATCH", f"/events/subscriptions/{_id(subscription_id)}", json=_clean(body))
|
|
122
|
+
|
|
123
|
+
def delete_subscription(self, subscription_id: str) -> None:
|
|
124
|
+
return self._client.request("DELETE", f"/events/subscriptions/{_id(subscription_id)}")
|
|
125
|
+
|
|
126
|
+
def rotate_subscription_secret(self, subscription_id: str) -> dict[str, Any]:
|
|
127
|
+
return self._client.request("POST", f"/events/subscriptions/{_id(subscription_id)}/rotate-secret")
|
|
128
|
+
|
|
129
|
+
def test_subscription(self, subscription_id: str) -> dict[str, Any]:
|
|
130
|
+
return self._client.request("POST", f"/events/subscriptions/{_id(subscription_id)}/test")
|
|
131
|
+
|
|
132
|
+
def create_rule(self, **body: Any) -> dict[str, Any]:
|
|
133
|
+
return self._client.request("POST", "/events/rules", json=_clean(body))
|
|
134
|
+
|
|
135
|
+
def list_rules(self, *, team_id: str | None = None, project_id: str | None = None) -> dict[str, Any]:
|
|
136
|
+
return self._client.request("GET", "/events/rules", params=_clean({"team_id": team_id, "project_id": project_id}))
|
|
137
|
+
|
|
138
|
+
def get_rule(self, rule_id: str) -> dict[str, Any]:
|
|
139
|
+
return self._client.request("GET", f"/events/rules/{_id(rule_id)}")
|
|
140
|
+
|
|
141
|
+
def update_rule(self, rule_id: str, **body: Any) -> dict[str, Any]:
|
|
142
|
+
return self._client.request("PATCH", f"/events/rules/{_id(rule_id)}", json=_clean(body))
|
|
143
|
+
|
|
144
|
+
def delete_rule(self, rule_id: str) -> None:
|
|
145
|
+
return self._client.request("DELETE", f"/events/rules/{_id(rule_id)}")
|
|
146
|
+
|
|
147
|
+
def preview_rule(self, **body: Any) -> dict[str, Any]:
|
|
148
|
+
return self._client.request("POST", "/events/rules/preview", json=_clean(body))
|
|
149
|
+
|
|
150
|
+
def test_rule(self, rule_id: str) -> dict[str, Any]:
|
|
151
|
+
return self._client.request("POST", f"/events/rules/{_id(rule_id)}/test")
|
|
152
|
+
|
|
153
|
+
def list_deliveries(
|
|
154
|
+
self,
|
|
155
|
+
*,
|
|
156
|
+
status: str | None = None,
|
|
157
|
+
dead_letter: bool | None = None,
|
|
158
|
+
subscription_id: str | None = None,
|
|
159
|
+
rule_id: str | None = None,
|
|
160
|
+
event_id: str | None = None,
|
|
161
|
+
team_id: str | None = None,
|
|
162
|
+
cursor: str | None = None,
|
|
163
|
+
limit: int | None = None,
|
|
164
|
+
) -> dict[str, Any]:
|
|
165
|
+
params = _clean({
|
|
166
|
+
"status": status,
|
|
167
|
+
"dead_letter": None if dead_letter is None else str(dead_letter).lower(),
|
|
168
|
+
"subscription_id": subscription_id,
|
|
169
|
+
"rule_id": rule_id,
|
|
170
|
+
"event_id": event_id,
|
|
171
|
+
"team_id": team_id,
|
|
172
|
+
"cursor": cursor,
|
|
173
|
+
"limit": limit,
|
|
174
|
+
})
|
|
175
|
+
return self._client.request("GET", "/events/deliveries", params=params)
|
|
176
|
+
|
|
177
|
+
def get_delivery(self, delivery_id: str) -> dict[str, Any]:
|
|
178
|
+
return self._client.request("GET", f"/events/deliveries/{_id(delivery_id)}")
|
|
179
|
+
|
|
180
|
+
def replay_delivery(self, delivery_id: str) -> dict[str, Any]:
|
|
181
|
+
return self._client.request("POST", f"/events/deliveries/{_id(delivery_id)}/replay")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stackshift
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.10.0
|
|
4
4
|
Summary: Official Python SDK for StackShift.
|
|
5
5
|
Author-email: StackShift <support@stackshift.cloud>
|
|
6
6
|
Project-URL: Homepage, https://stackshift.cloud
|
|
@@ -51,6 +51,8 @@ computer.files.remove("app/tmp", recursive=True)
|
|
|
51
51
|
|
|
52
52
|
`upload_dir` skips `.gitignore`d files in a git folder unless you pass `include_ignored=True`, and keeps modes, symlinks and modification times.
|
|
53
53
|
|
|
54
|
+
`computers.ensure_project()` returns the project computers go in (`id`, `name`, `created`), making one named "Computers" if the account has none; it needs a user token.
|
|
55
|
+
|
|
54
56
|
Pick `vcpus` and `memory_gb` from the template's sizes (`templates()` lists them), for example 2 vCPU / 8 GB or 4 vCPU / 16 GB. `region` picks where it starts; `computers.regions(project_id)` lists the regions open now.
|
|
55
57
|
|
|
56
58
|
Tell people what an agent is doing. The dashboard shows the task and next step beside the screen, and `ask_owner` carries the next step on its card.
|
|
@@ -181,6 +183,22 @@ computer.agent_conversations()
|
|
|
181
183
|
computer.agent_events(conversation["id"], after_seq=10, limit=50)
|
|
182
184
|
```
|
|
183
185
|
|
|
186
|
+
Providers are `COMPUTER_AGENT_PROVIDERS` (`claude`, `codex`, `gemini`, `opencode`, `cursor`, `copilot`, `amp`, `qwen`). Attach files, read the result, and try one task several ways:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
computer.agent_providers()
|
|
190
|
+
computer.agent_models(provider="claude")
|
|
191
|
+
spec = computer.attach_agent_file("./spec.md")
|
|
192
|
+
conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
|
|
193
|
+
computer.agent_result(conversation["id"], wait=True)
|
|
194
|
+
computer.agent_turns(limit=20)
|
|
195
|
+
|
|
196
|
+
fanout = computer.prompt_agent(prompts=["fix it with a retry", "fix it with a lock"], provider="codex")
|
|
197
|
+
done = computer.agent_fanout(fanout["id"])
|
|
198
|
+
computer.keep_agent_fork(fanout["id"], done["forks"][0]["computer_id"])
|
|
199
|
+
computer.agent_fanouts()
|
|
200
|
+
```
|
|
201
|
+
|
|
184
202
|
`computers.keys.create(project_id, name, scopes=["computers:read"])` limits a key to `computers:read`, `computers:write`, `computers:use` or `computers:delete`. A stuck large upload resumes with `computers.resume_upload(computer_id, transfer_id, upload_id, part_md5)`.
|
|
185
203
|
|
|
186
204
|
An agent can get its own key without any existing key. The functions below send no `Authorization` header:
|
|
@@ -350,6 +368,26 @@ valid = stackshift.mail.webhooks.verify_signature(
|
|
|
350
368
|
|
|
351
369
|
Webhook handlers should be idempotent. StackShift retries non-2xx responses. Delivery events do not include full email bodies or OTP codes by default.
|
|
352
370
|
|
|
371
|
+
## Platform events
|
|
372
|
+
|
|
373
|
+
Every StackShift event reaches your endpoint signed with `StackShift-Signature`. `events.verify` checks the signature in constant time, refuses timestamps older than five minutes (`tolerance_seconds` changes that) and returns the parsed event. Failures raise `EventSignatureError` with a `code` of `missing_signature`, `invalid_signature`, `expired` or `invalid_body`:
|
|
374
|
+
|
|
375
|
+
```python
|
|
376
|
+
from stackshift import EventSignatureError
|
|
377
|
+
|
|
378
|
+
try:
|
|
379
|
+
event = stackshift.events.verify(
|
|
380
|
+
raw_body=request.get_data(),
|
|
381
|
+
signature_header=request.headers.get("StackShift-Signature"),
|
|
382
|
+
secret=os.environ["STACKSHIFT_WEBHOOK_SECRET"],
|
|
383
|
+
)
|
|
384
|
+
except EventSignatureError as error:
|
|
385
|
+
return error.code, 400
|
|
386
|
+
print(event["type"], event["subject"]["id"])
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
`events` also wraps the API: `catalog`, `list`, `get`, `create_subscription`, `list_subscriptions`, `update_subscription`, `delete_subscription`, `create_rule`, `list_rules`, `update_rule`, `delete_rule`, `preview_rule`, `test_rule`, `list_deliveries` and `replay_delivery`.
|
|
390
|
+
|
|
353
391
|
## Mailboxes
|
|
354
392
|
|
|
355
393
|
Host real mailboxes on your own domain. The mailbox owner gets an invitation by email and sets their own password.
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
stackshift/__init__.py,sha256=
|
|
1
|
+
stackshift/__init__.py,sha256=bQb_Up3QBRwpT-26qIDD5JYs86L-Hf4reX-m5yD90EQ,5849
|
|
2
2
|
stackshift/agents.py,sha256=8Pdp1ujQHTfAimmMun8RmzXNlmvsEX_WV65KjMiu-CU,4292
|
|
3
3
|
stackshift/ai_credits.py,sha256=2u5zGSBo_spHqgYJhtmChaEiBq9jUVaTjR1uprxMpNQ,1142
|
|
4
|
-
stackshift/assets.py,sha256=
|
|
4
|
+
stackshift/assets.py,sha256=kmPkWr7qaDJX0XsvVgUTJ2q5IZ5mDZ73w59UXDnS4ok,24130
|
|
5
5
|
stackshift/assets_dam.py,sha256=dz0QgSZuQcwSSYoWFqy1pCx3xgMGYZLc9tCcQE0_kYo,6659
|
|
6
6
|
stackshift/assets_media.py,sha256=S_7TWu6hm5I8WUPMfQsGE9U15mDiYRG4ygXJzWqwbDE,1523
|
|
7
7
|
stackshift/assets_platform.py,sha256=w2Eke0YFXinmtHt1oaZlaiP_J32VymfhVWWLOYrX93M,4125
|
|
8
|
+
stackshift/assets_transforms.py,sha256=WMc-LZlp-rVOYmTNiDzlQTMi9OCZp4XMHoxKEQIL14k,1999
|
|
8
9
|
stackshift/assets_video.py,sha256=KBIOTsVspHcMltkELsbTmfu-VB6_36dpYQ7HKTqAa2E,2374
|
|
9
|
-
stackshift/
|
|
10
|
-
stackshift/
|
|
11
|
-
stackshift/computers.py,sha256=jXXXQ3V2cy9LiNhoYofDAC5RwwV0zV_5TJr4cD0G9Y4,51372
|
|
10
|
+
stackshift/client.py,sha256=5N-nO7l4vOp8DyIfxSqbm6bYzpKN7aok16cMAGQC-pM,4728
|
|
11
|
+
stackshift/computers.py,sha256=QQr5eNz_CKPGeHUgp0FOgp9-ZNrYRf59mL_H4r8h2g0,55052
|
|
12
12
|
stackshift/computers_adapters.py,sha256=AVdQjh3GSmD6Azi7DuoWaNMmwxsTVLlxm5GgxAqL-R0,17853
|
|
13
13
|
stackshift/computers_transfer.py,sha256=3YJV4Ld531C5k0teoL0x18qtD98pXpcjxtR_oZd-7ZU,23653
|
|
14
14
|
stackshift/databases.py,sha256=X7C8kaDUCTc8I8nPye9D8FOS3mOR1h62qPzrJB0iwvs,10916
|
|
15
|
+
stackshift/events.py,sha256=NzoN9WZlNanmSkLc87x7F2EWWZXLHc8Uc0QscQAJhpw,7056
|
|
15
16
|
stackshift/hosted_agents.py,sha256=rdQflIFOKSGvcSInrBK3qplOC3UP3u1wyZ5MoVYOpKk,3492
|
|
16
17
|
stackshift/mail.py,sha256=oWiDwksiAt77EmHBfIf4KH34zvzY5tydUuU0x8wbus4,16868
|
|
17
18
|
stackshift/mail_advanced.py,sha256=sLte3we0Oy3pSuwjl5c4lfELH6gzaSUKug_WZDUB2DE,4363
|
|
@@ -39,7 +40,7 @@ stackshift/support_action_types.py,sha256=i7xADrXFSIHJaqwcS77LU4jvni5JKrRUzot5Wa
|
|
|
39
40
|
stackshift/support_actions.py,sha256=tZYlb8gdE875SKZdzfN01jfEfIQTyH08XThgCYQ820o,8744
|
|
40
41
|
stackshift/teams.py,sha256=SjTjmQY_X8cBZPb61k3N3Vv5qbNNkWhuBkLwmZjQK-Q,10608
|
|
41
42
|
stackshift/workload_security.py,sha256=5JtJH9fX1kqSY3ipXUa79JslUULWsN5_gyn9tTGfzlA,2941
|
|
42
|
-
stackshift-1.
|
|
43
|
-
stackshift-1.
|
|
44
|
-
stackshift-1.
|
|
45
|
-
stackshift-1.
|
|
43
|
+
stackshift-1.10.0.dist-info/METADATA,sha256=8HAhwe0U_iWOMxXF0be8_ag0ivID9IiMr_kEzkmbWc0,39990
|
|
44
|
+
stackshift-1.10.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
45
|
+
stackshift-1.10.0.dist-info/top_level.txt,sha256=qe3uWsu_O9mNtq7bIck9Y8rjTIMrH0kzgAlGFDoRGqs,11
|
|
46
|
+
stackshift-1.10.0.dist-info/RECORD,,
|
stackshift/assets_workflows.py
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
from urllib.parse import quote, urlencode
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class AssetWorkflowsMixin:
|
|
8
|
-
"""Typed route helpers for deterministic media and governed asset workflows."""
|
|
9
|
-
|
|
10
|
-
_client: Any
|
|
11
|
-
|
|
12
|
-
def create_transformation_v2(
|
|
13
|
-
self, name: str, definition: dict[str, Any], *, eager: bool = False
|
|
14
|
-
) -> dict[str, Any]:
|
|
15
|
-
return self._client.request(
|
|
16
|
-
"POST", "/assets/transformations",
|
|
17
|
-
json={"name": name, "definition": definition, "eager": eager},
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
def estimate_transform(
|
|
21
|
-
self, asset_id: str, version_id: str, definition: dict[str, Any]
|
|
22
|
-
) -> dict[str, Any]:
|
|
23
|
-
return self._client.request(
|
|
24
|
-
"POST", f"/assets/{quote(asset_id, safe='')}/transforms/estimate",
|
|
25
|
-
json={"version_id": version_id, "definition": definition},
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
def materialize_transform(
|
|
29
|
-
self,
|
|
30
|
-
asset_id: str,
|
|
31
|
-
*,
|
|
32
|
-
definition: dict[str, Any] | None = None,
|
|
33
|
-
preset: str | None = None,
|
|
34
|
-
idempotency_key: str | None = None,
|
|
35
|
-
) -> dict[str, Any]:
|
|
36
|
-
payload = {key: value for key, value in {
|
|
37
|
-
"definition": definition, "preset": preset,
|
|
38
|
-
}.items() if value not in (None, "")}
|
|
39
|
-
headers = {"Idempotency-Key": idempotency_key} if idempotency_key else None
|
|
40
|
-
return self._client.request(
|
|
41
|
-
"POST", f"/assets/{quote(asset_id, safe='')}/transforms", json=payload, headers=headers
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
def derivatives(self, asset_id: str) -> dict[str, Any]:
|
|
45
|
-
return self._client.request("GET", f"/assets/{quote(asset_id, safe='')}/derivatives")
|
|
46
|
-
|
|
47
|
-
def generate(
|
|
48
|
-
self, payload: dict[str, Any], *, idempotency_key: str
|
|
49
|
-
) -> dict[str, Any]:
|
|
50
|
-
return self._client.request(
|
|
51
|
-
"POST", "/assets/generations", json=payload,
|
|
52
|
-
headers={"Idempotency-Key": idempotency_key},
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
def automation(self) -> dict[str, Any]:
|
|
56
|
-
return self._client.request("GET", "/assets/automation")
|
|
57
|
-
|
|
58
|
-
def workflow_catalog(self) -> dict[str, Any]:
|
|
59
|
-
return self._client.request("GET", "/assets/workflows/catalog")
|
|
60
|
-
|
|
61
|
-
def create_workflow(self, payload: dict[str, Any]) -> dict[str, Any]:
|
|
62
|
-
return self._client.request("POST", "/assets/workflows", json=payload)
|
|
63
|
-
|
|
64
|
-
def workflows(self, *, page: int = 1, per_page: int = 20) -> list[dict[str, Any]]:
|
|
65
|
-
query = urlencode({"page": page, "per_page": per_page})
|
|
66
|
-
return self._client.request("GET", f"/assets/workflows?{query}")
|
|
67
|
-
|
|
68
|
-
def workflow(self, workflow_id: str) -> dict[str, Any]:
|
|
69
|
-
return self._client.request("GET", self._workflow_path(workflow_id))
|
|
70
|
-
|
|
71
|
-
def update_workflow_draft(
|
|
72
|
-
self, workflow_id: str, payload: dict[str, Any]
|
|
73
|
-
) -> dict[str, Any]:
|
|
74
|
-
return self._client.request(
|
|
75
|
-
"PUT", f"{self._workflow_path(workflow_id)}/draft", json=payload
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
def validate_workflow(self, workflow_id: str) -> dict[str, Any]:
|
|
79
|
-
return self._client.request("POST", f"{self._workflow_path(workflow_id)}/validate")
|
|
80
|
-
|
|
81
|
-
def publish_workflow(
|
|
82
|
-
self, workflow_id: str, expected_revision: int
|
|
83
|
-
) -> dict[str, Any]:
|
|
84
|
-
return self._client.request(
|
|
85
|
-
"POST", f"{self._workflow_path(workflow_id)}/publish",
|
|
86
|
-
json={"expected_revision": expected_revision},
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
def activate_workflow(
|
|
90
|
-
self, workflow_id: str, version_id: str, expected_revision: int
|
|
91
|
-
) -> None:
|
|
92
|
-
self._client.request(
|
|
93
|
-
"POST", f"{self._workflow_path(workflow_id)}/activate",
|
|
94
|
-
json={"version_id": version_id, "expected_revision": expected_revision},
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
def workflow_versions(self, workflow_id: str) -> list[dict[str, Any]]:
|
|
98
|
-
return self._client.request("GET", f"{self._workflow_path(workflow_id)}/versions")
|
|
99
|
-
|
|
100
|
-
def run_workflow(
|
|
101
|
-
self, workflow_id: str, payload: dict[str, Any] | None = None,
|
|
102
|
-
*, idempotency_key: str | None = None,
|
|
103
|
-
) -> dict[str, Any]:
|
|
104
|
-
headers = {"Idempotency-Key": idempotency_key} if idempotency_key else None
|
|
105
|
-
return self._client.request(
|
|
106
|
-
"POST", f"{self._workflow_path(workflow_id)}/run",
|
|
107
|
-
json=payload or {}, headers=headers,
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
def workflow_runs(
|
|
111
|
-
self, workflow_id: str, *, page: int = 1, per_page: int = 20
|
|
112
|
-
) -> list[dict[str, Any]]:
|
|
113
|
-
query = urlencode({"page": page, "per_page": per_page})
|
|
114
|
-
return self._client.request(
|
|
115
|
-
"GET", f"{self._workflow_path(workflow_id)}/runs?{query}"
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
def workflow_run(self, run_id: str) -> dict[str, Any]:
|
|
119
|
-
return self._client.request("GET", self._workflow_run_path(run_id))
|
|
120
|
-
|
|
121
|
-
def cancel_workflow_run(self, run_id: str) -> dict[str, Any]:
|
|
122
|
-
return self._client.request("POST", f"{self._workflow_run_path(run_id)}/cancel")
|
|
123
|
-
|
|
124
|
-
def retry_workflow_run(self, run_id: str) -> dict[str, Any]:
|
|
125
|
-
return self._client.request("POST", f"{self._workflow_run_path(run_id)}/retry")
|
|
126
|
-
|
|
127
|
-
def workflow_approvals(self, status: str | None = None) -> list[dict[str, Any]]:
|
|
128
|
-
if status:
|
|
129
|
-
return self._client.request(
|
|
130
|
-
"GET", f"/assets/workflows/approvals?{urlencode({'status': status})}"
|
|
131
|
-
)
|
|
132
|
-
return self._client.request("GET", "/assets/workflows/approvals")
|
|
133
|
-
|
|
134
|
-
def decide_workflow_approval(
|
|
135
|
-
self, approval_id: str, approved: bool, payload: dict[str, Any] | None = None
|
|
136
|
-
) -> dict[str, Any]:
|
|
137
|
-
return (
|
|
138
|
-
self.approve_workflow(approval_id, payload)
|
|
139
|
-
if approved else self.reject_workflow(approval_id, payload)
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
def approve_workflow(
|
|
143
|
-
self, approval_id: str, payload: dict[str, Any] | None = None
|
|
144
|
-
) -> dict[str, Any]:
|
|
145
|
-
return self._client.request(
|
|
146
|
-
"POST", f"/assets/workflows/approvals/{quote(approval_id, safe='')}/approve",
|
|
147
|
-
json=payload or {},
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
def reject_workflow(
|
|
151
|
-
self, approval_id: str, payload: dict[str, Any] | None = None
|
|
152
|
-
) -> dict[str, Any]:
|
|
153
|
-
return self._client.request(
|
|
154
|
-
"POST", f"/assets/workflows/approvals/{quote(approval_id, safe='')}/reject",
|
|
155
|
-
json=payload or {},
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
def workflow_connections(self) -> list[dict[str, Any]]:
|
|
159
|
-
return self._client.request("GET", "/assets/workflows/connections")
|
|
160
|
-
|
|
161
|
-
def create_workflow_connection(self, payload: dict[str, Any]) -> dict[str, Any]:
|
|
162
|
-
return self._client.request("POST", "/assets/workflows/connections", json=payload)
|
|
163
|
-
|
|
164
|
-
def rotate_workflow_connection_credential(
|
|
165
|
-
self, connection_id: str, payload: dict[str, Any]
|
|
166
|
-
) -> dict[str, Any]:
|
|
167
|
-
return self._client.request(
|
|
168
|
-
"POST",
|
|
169
|
-
f"/assets/workflows/connections/{quote(connection_id, safe='')}/credential/rotate",
|
|
170
|
-
json=payload,
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
def rotate_workflow_inbound_hook(self, workflow_id: str) -> dict[str, Any]:
|
|
174
|
-
return self._client.request(
|
|
175
|
-
"POST", f"{self._workflow_path(workflow_id)}/inbound-hook/rotate"
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
@staticmethod
|
|
179
|
-
def _workflow_path(workflow_id: str) -> str:
|
|
180
|
-
return f"/assets/workflows/{quote(workflow_id, safe='')}"
|
|
181
|
-
|
|
182
|
-
@staticmethod
|
|
183
|
-
def _workflow_run_path(run_id: str) -> str:
|
|
184
|
-
return f"/assets/workflows/runs/{quote(run_id, safe='')}"
|
|
File without changes
|
|
File without changes
|