stackshift 1.9.0__tar.gz → 1.10.0__tar.gz

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.
Files changed (82) hide show
  1. {stackshift-1.9.0/stackshift.egg-info → stackshift-1.10.0}/PKG-INFO +22 -1
  2. stackshift-1.9.0/PKG-INFO → stackshift-1.10.0/README.md +21 -12
  3. {stackshift-1.9.0 → stackshift-1.10.0}/pyproject.toml +1 -1
  4. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/__init__.py +4 -0
  5. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/assets.py +2 -2
  6. stackshift-1.10.0/stackshift/assets_transforms.py +56 -0
  7. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/client.py +2 -0
  8. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/computers.py +6 -0
  9. stackshift-1.10.0/stackshift/events.py +181 -0
  10. stackshift-1.9.0/README.md → stackshift-1.10.0/stackshift.egg-info/PKG-INFO +33 -0
  11. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift.egg-info/SOURCES.txt +4 -2
  12. stackshift-1.9.0/tests/test_assets_workflows.py → stackshift-1.10.0/tests/test_assets_transforms.py +1 -6
  13. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_computers_agent.py +4 -0
  14. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_computers_routes.py +1 -0
  15. stackshift-1.10.0/tests/test_events.py +52 -0
  16. stackshift-1.9.0/stackshift/assets_workflows.py +0 -184
  17. {stackshift-1.9.0 → stackshift-1.10.0}/setup.cfg +0 -0
  18. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/agents.py +0 -0
  19. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/ai_credits.py +0 -0
  20. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/assets_dam.py +0 -0
  21. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/assets_media.py +0 -0
  22. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/assets_platform.py +0 -0
  23. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/assets_video.py +0 -0
  24. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/computers_adapters.py +0 -0
  25. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/computers_transfer.py +0 -0
  26. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/databases.py +0 -0
  27. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/hosted_agents.py +0 -0
  28. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail.py +0 -0
  29. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_advanced.py +0 -0
  30. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_agent_inboxes.py +0 -0
  31. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_agreements.py +0 -0
  32. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_billing.py +0 -0
  33. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_brands.py +0 -0
  34. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_campaigns.py +0 -0
  35. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_events_webhooks.py +0 -0
  36. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_exports.py +0 -0
  37. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_inbox_webhooks.py +0 -0
  38. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_mailboxes.py +0 -0
  39. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_marketing.py +0 -0
  40. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_migration.py +0 -0
  41. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_reputation.py +0 -0
  42. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_streams.py +0 -0
  43. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_team_inboxes.py +0 -0
  44. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/mail_tracking.py +0 -0
  45. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/partner.py +0 -0
  46. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/projects.py +0 -0
  47. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/support_action_manifest.py +0 -0
  48. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/support_action_receiver.py +0 -0
  49. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/support_action_sqlite.py +0 -0
  50. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/support_action_types.py +0 -0
  51. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/support_actions.py +0 -0
  52. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/teams.py +0 -0
  53. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift/workload_security.py +0 -0
  54. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift.egg-info/dependency_links.txt +0 -0
  55. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift.egg-info/requires.txt +0 -0
  56. {stackshift-1.9.0 → stackshift-1.10.0}/stackshift.egg-info/top_level.txt +0 -0
  57. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_agents.py +0 -0
  58. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_ai_credits.py +0 -0
  59. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_assets_media.py +0 -0
  60. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_assets_platform.py +0 -0
  61. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_computers.py +0 -0
  62. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_computers_adapters.py +0 -0
  63. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_computers_controls.py +0 -0
  64. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_databases.py +0 -0
  65. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_hosted_agents.py +0 -0
  66. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail.py +0 -0
  67. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_advanced.py +0 -0
  68. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_agent_inboxes.py +0 -0
  69. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_agreements.py +0 -0
  70. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_diagnostics.py +0 -0
  71. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_events_webhooks.py +0 -0
  72. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_exports.py +0 -0
  73. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_inbox_webhooks.py +0 -0
  74. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_mailboxes.py +0 -0
  75. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_platform.py +0 -0
  76. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_simulation.py +0 -0
  77. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_subscribers.py +0 -0
  78. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_team_inboxes.py +0 -0
  79. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_mail_tracking.py +0 -0
  80. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_partner.py +0 -0
  81. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_support_actions.py +0 -0
  82. {stackshift-1.9.0 → stackshift-1.10.0}/tests/test_teams.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stackshift
3
- Version: 1.9.0
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
@@ -187,6 +187,7 @@ Providers are `COMPUTER_AGENT_PROVIDERS` (`claude`, `codex`, `gemini`, `opencode
187
187
 
188
188
  ```python
189
189
  computer.agent_providers()
190
+ computer.agent_models(provider="claude")
190
191
  spec = computer.attach_agent_file("./spec.md")
191
192
  conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
192
193
  computer.agent_result(conversation["id"], wait=True)
@@ -367,6 +368,26 @@ valid = stackshift.mail.webhooks.verify_signature(
367
368
 
368
369
  Webhook handlers should be idempotent. StackShift retries non-2xx responses. Delivery events do not include full email bodies or OTP codes by default.
369
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
+
370
391
  ## Mailboxes
371
392
 
372
393
  Host real mailboxes on your own domain. The mailbox owner gets an invitation by email and sets their own password.
@@ -1,15 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: stackshift
3
- Version: 1.9.0
4
- Summary: Official Python SDK for StackShift.
5
- Author-email: StackShift <support@stackshift.cloud>
6
- Project-URL: Homepage, https://stackshift.cloud
7
- Project-URL: Documentation, https://docs.stackshift.cloud
8
- Classifier: Programming Language :: Python :: 3
9
- Requires-Python: >=3.9
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: requests>=2.31
12
-
13
1
  # StackShift Python SDK
14
2
 
15
3
  Official Python SDK for StackShift.
@@ -187,6 +175,7 @@ Providers are `COMPUTER_AGENT_PROVIDERS` (`claude`, `codex`, `gemini`, `opencode
187
175
 
188
176
  ```python
189
177
  computer.agent_providers()
178
+ computer.agent_models(provider="claude")
190
179
  spec = computer.attach_agent_file("./spec.md")
191
180
  conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
192
181
  computer.agent_result(conversation["id"], wait=True)
@@ -367,6 +356,26 @@ valid = stackshift.mail.webhooks.verify_signature(
367
356
 
368
357
  Webhook handlers should be idempotent. StackShift retries non-2xx responses. Delivery events do not include full email bodies or OTP codes by default.
369
358
 
359
+ ## Platform events
360
+
361
+ 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`:
362
+
363
+ ```python
364
+ from stackshift import EventSignatureError
365
+
366
+ try:
367
+ event = stackshift.events.verify(
368
+ raw_body=request.get_data(),
369
+ signature_header=request.headers.get("StackShift-Signature"),
370
+ secret=os.environ["STACKSHIFT_WEBHOOK_SECRET"],
371
+ )
372
+ except EventSignatureError as error:
373
+ return error.code, 400
374
+ print(event["type"], event["subject"]["id"])
375
+ ```
376
+
377
+ `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`.
378
+
370
379
  ## Mailboxes
371
380
 
372
381
  Host real mailboxes on your own domain. The mailbox owner gets an invitation by email and sets their own password.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "stackshift"
7
- version = "1.9.0"
7
+ version = "1.10.0"
8
8
  description = "Official Python SDK for StackShift."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -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,
@@ -138,6 +139,9 @@ __all__ = [
138
139
  "asset_transform_spec",
139
140
  "get_asset_transform_preset",
140
141
  "verify_webhook_signature",
142
+ "EventSignatureError",
143
+ "EventsClient",
144
+ "verify_event",
141
145
  ]
142
146
 
143
147
  from .support_actions import (ActionProtocolError, sign_action, verify_action, verify_receipt, encode_receipt)
@@ -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 .assets_workflows import AssetWorkflowsMixin
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(AssetWorkflowsMixin):
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")
@@ -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)
@@ -386,6 +386,9 @@ class ComputersClient:
386
386
  def agent_providers(self, computer_id: str, *, refresh: bool = False) -> list[dict[str, Any]]:
387
387
  return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/providers", params=_params(refresh="1" if refresh else None))["providers"]
388
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
+
389
392
  def agent_result(self, computer_id: str, conversation_id: str, *, wait: bool = False) -> dict[str, Any]:
390
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))
391
394
 
@@ -874,6 +877,9 @@ class Computer:
874
877
  def agent_providers(self, *, refresh: bool = False) -> list[dict[str, Any]]:
875
878
  return self._client.agent_providers(self.id, refresh=refresh)
876
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
+
877
883
  def agent_result(self, conversation_id: str, *, wait: bool = False) -> dict[str, Any]:
878
884
  return self._client.agent_result(self.id, conversation_id, wait=wait)
879
885
 
@@ -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,3 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: stackshift
3
+ Version: 1.10.0
4
+ Summary: Official Python SDK for StackShift.
5
+ Author-email: StackShift <support@stackshift.cloud>
6
+ Project-URL: Homepage, https://stackshift.cloud
7
+ Project-URL: Documentation, https://docs.stackshift.cloud
8
+ Classifier: Programming Language :: Python :: 3
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: requests>=2.31
12
+
1
13
  # StackShift Python SDK
2
14
 
3
15
  Official Python SDK for StackShift.
@@ -175,6 +187,7 @@ Providers are `COMPUTER_AGENT_PROVIDERS` (`claude`, `codex`, `gemini`, `opencode
175
187
 
176
188
  ```python
177
189
  computer.agent_providers()
190
+ computer.agent_models(provider="claude")
178
191
  spec = computer.attach_agent_file("./spec.md")
179
192
  conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
180
193
  computer.agent_result(conversation["id"], wait=True)
@@ -355,6 +368,26 @@ valid = stackshift.mail.webhooks.verify_signature(
355
368
 
356
369
  Webhook handlers should be idempotent. StackShift retries non-2xx responses. Delivery events do not include full email bodies or OTP codes by default.
357
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
+
358
391
  ## Mailboxes
359
392
 
360
393
  Host real mailboxes on your own domain. The mailbox owner gets an invitation by email and sets their own password.
@@ -7,13 +7,14 @@ stackshift/assets.py
7
7
  stackshift/assets_dam.py
8
8
  stackshift/assets_media.py
9
9
  stackshift/assets_platform.py
10
+ stackshift/assets_transforms.py
10
11
  stackshift/assets_video.py
11
- stackshift/assets_workflows.py
12
12
  stackshift/client.py
13
13
  stackshift/computers.py
14
14
  stackshift/computers_adapters.py
15
15
  stackshift/computers_transfer.py
16
16
  stackshift/databases.py
17
+ stackshift/events.py
17
18
  stackshift/hosted_agents.py
18
19
  stackshift/mail.py
19
20
  stackshift/mail_advanced.py
@@ -50,13 +51,14 @@ tests/test_agents.py
50
51
  tests/test_ai_credits.py
51
52
  tests/test_assets_media.py
52
53
  tests/test_assets_platform.py
53
- tests/test_assets_workflows.py
54
+ tests/test_assets_transforms.py
54
55
  tests/test_computers.py
55
56
  tests/test_computers_adapters.py
56
57
  tests/test_computers_agent.py
57
58
  tests/test_computers_controls.py
58
59
  tests/test_computers_routes.py
59
60
  tests/test_databases.py
61
+ tests/test_events.py
60
62
  tests/test_hosted_agents.py
61
63
  tests/test_mail.py
62
64
  tests/test_mail_advanced.py
@@ -10,7 +10,7 @@ class FakeClient:
10
10
  return {"method": method, "path": path}
11
11
 
12
12
 
13
- def test_transform_generation_and_workflow_routes():
13
+ def test_transform_and_generation_routes():
14
14
  transport = FakeClient()
15
15
  assets = AssetsClient(transport)
16
16
 
@@ -44,8 +44,3 @@ def test_transform_generation_and_workflow_routes():
44
44
  idempotency_key="generation-1",
45
45
  )
46
46
  assert transport.calls[-1][2]["headers"]["Idempotency-Key"] == "generation-1"
47
-
48
- assets.publish_workflow("workflow/1", 4)
49
- method, path, options = transport.calls[-1]
50
- assert (method, path) == ("POST", "/assets/workflows/workflow%2F1/publish")
51
- assert options["json"] == {"expected_revision": 4}
@@ -50,6 +50,10 @@ class ComputerAgentTests(unittest.TestCase):
50
50
  self.assertEqual((self.last()["method"], self.last()["path"], self.last()["params"]), ("GET", f"{BASE}/providers", None))
51
51
  self.computer.agent_providers(refresh=True)
52
52
  self.assertEqual(self.last()["params"], {"refresh": "1"})
53
+ self.computer.agent_models()
54
+ self.assertEqual((self.last()["method"], self.last()["path"], self.last()["params"]), ("GET", f"{BASE}/models", None))
55
+ self.computer.agent_models(provider="codex", secret_binding_id="b1")
56
+ self.assertEqual(self.last()["params"], {"provider": "codex", "secret_binding_id": "b1"})
53
57
  self.computer.agent_result("k1", wait=True)
54
58
  self.assertEqual((self.last()["path"], self.last()["params"]), (f"{BASE}/conversations/k1/result", {"wait": "1"}))
55
59
  self.computer.agent_turns(limit=20)
@@ -87,6 +87,7 @@ def table(sdk, computer):
87
87
  "steerComputerAgent": lambda r: computer.steer_agent("conv1", "stop"),
88
88
  "promptComputerAgent": lambda r: computer.prompt_agent("fix it"),
89
89
  "listComputerAgentProviders": lambda r: computer.agent_providers(),
90
+ "listComputerAgentModels": lambda r: computer.agent_models(),
90
91
  "getComputerAgentResult": lambda r: computer.agent_result("conv1"),
91
92
  "listComputerAgentTurns": lambda r: computer.agent_turns(),
92
93
  "listComputerAgentFanouts": lambda r: computer.agent_fanouts(),
@@ -0,0 +1,52 @@
1
+ import hashlib
2
+ import hmac
3
+ import json
4
+ import sys
5
+ import time
6
+ import types
7
+ import unittest
8
+
9
+ if "requests" not in sys.modules:
10
+ requests_stub = types.ModuleType("requests")
11
+ requests_stub.Session = object
12
+ sys.modules["requests"] = requests_stub
13
+
14
+ from stackshift import EventSignatureError, StackShift, verify_event
15
+
16
+ SECRET = "whsec_test"
17
+ EVENT = {"id": "evt_1", "type": "deploy.failed", "version": 1, "time": "2026-11-26T10:00:00Z", "product": "hosting", "subject": {"kind": "deployment", "id": "dep_1"}, "actor": {"type": "system"}, "data": {}}
18
+ BODY = json.dumps(EVENT)
19
+
20
+
21
+ def sign(timestamp, secret=SECRET):
22
+ digest = hmac.new(secret.encode(), f"{timestamp}.{BODY}".encode(), hashlib.sha256).hexdigest()
23
+ return f"t={timestamp},v1={digest}"
24
+
25
+
26
+ class EventsVerifyTests(unittest.TestCase):
27
+ def test_valid(self):
28
+ now = int(time.time())
29
+ self.assertEqual(verify_event(raw_body=BODY, signature_header=sign(now), secret=SECRET), EVENT)
30
+ self.assertEqual(verify_event(raw_body=BODY.encode(), signature_header=sign(now), secret=SECRET)["id"], "evt_1")
31
+ client = StackShift(api_key="sk_test", session=object())
32
+ self.assertEqual(client.events.verify(raw_body=BODY, signature_header=sign(now), secret=SECRET)["type"], "deploy.failed")
33
+
34
+ def test_bad_signature(self):
35
+ now = int(time.time())
36
+ with self.assertRaises(EventSignatureError) as raised:
37
+ verify_event(raw_body=BODY, signature_header=sign(now, "other"), secret=SECRET)
38
+ self.assertEqual(raised.exception.code, "invalid_signature")
39
+ with self.assertRaises(EventSignatureError) as raised:
40
+ verify_event(raw_body=BODY, signature_header=None, secret=SECRET)
41
+ self.assertEqual(raised.exception.code, "missing_signature")
42
+
43
+ def test_expired(self):
44
+ old = int(time.time()) - 1000
45
+ with self.assertRaises(EventSignatureError) as raised:
46
+ verify_event(raw_body=BODY, signature_header=sign(old), secret=SECRET)
47
+ self.assertEqual(raised.exception.code, "expired")
48
+ self.assertEqual(verify_event(raw_body=BODY, signature_header=sign(old), secret=SECRET, tolerance_seconds=2000)["id"], "evt_1")
49
+
50
+
51
+ if __name__ == "__main__":
52
+ unittest.main()
@@ -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