stackshift 1.8.0__tar.gz → 1.9.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 (79) hide show
  1. {stackshift-1.8.0/stackshift.egg-info → stackshift-1.9.0}/PKG-INFO +18 -1
  2. stackshift-1.8.0/PKG-INFO → stackshift-1.9.0/README.md +17 -12
  3. {stackshift-1.8.0 → stackshift-1.9.0}/pyproject.toml +1 -1
  4. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/__init__.py +2 -1
  5. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/computers.py +55 -4
  6. stackshift-1.8.0/README.md → stackshift-1.9.0/stackshift.egg-info/PKG-INFO +29 -0
  7. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift.egg-info/SOURCES.txt +1 -0
  8. stackshift-1.9.0/tests/test_computers_agent.py +76 -0
  9. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_computers_routes.py +8 -1
  10. {stackshift-1.8.0 → stackshift-1.9.0}/setup.cfg +0 -0
  11. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/agents.py +0 -0
  12. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/ai_credits.py +0 -0
  13. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/assets.py +0 -0
  14. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/assets_dam.py +0 -0
  15. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/assets_media.py +0 -0
  16. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/assets_platform.py +0 -0
  17. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/assets_video.py +0 -0
  18. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/assets_workflows.py +0 -0
  19. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/client.py +0 -0
  20. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/computers_adapters.py +0 -0
  21. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/computers_transfer.py +0 -0
  22. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/databases.py +0 -0
  23. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/hosted_agents.py +0 -0
  24. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail.py +0 -0
  25. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_advanced.py +0 -0
  26. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_agent_inboxes.py +0 -0
  27. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_agreements.py +0 -0
  28. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_billing.py +0 -0
  29. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_brands.py +0 -0
  30. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_campaigns.py +0 -0
  31. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_events_webhooks.py +0 -0
  32. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_exports.py +0 -0
  33. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_inbox_webhooks.py +0 -0
  34. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_mailboxes.py +0 -0
  35. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_marketing.py +0 -0
  36. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_migration.py +0 -0
  37. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_reputation.py +0 -0
  38. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_streams.py +0 -0
  39. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_team_inboxes.py +0 -0
  40. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/mail_tracking.py +0 -0
  41. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/partner.py +0 -0
  42. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/projects.py +0 -0
  43. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/support_action_manifest.py +0 -0
  44. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/support_action_receiver.py +0 -0
  45. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/support_action_sqlite.py +0 -0
  46. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/support_action_types.py +0 -0
  47. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/support_actions.py +0 -0
  48. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/teams.py +0 -0
  49. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift/workload_security.py +0 -0
  50. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift.egg-info/dependency_links.txt +0 -0
  51. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift.egg-info/requires.txt +0 -0
  52. {stackshift-1.8.0 → stackshift-1.9.0}/stackshift.egg-info/top_level.txt +0 -0
  53. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_agents.py +0 -0
  54. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_ai_credits.py +0 -0
  55. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_assets_media.py +0 -0
  56. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_assets_platform.py +0 -0
  57. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_assets_workflows.py +0 -0
  58. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_computers.py +0 -0
  59. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_computers_adapters.py +0 -0
  60. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_computers_controls.py +0 -0
  61. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_databases.py +0 -0
  62. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_hosted_agents.py +0 -0
  63. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail.py +0 -0
  64. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_advanced.py +0 -0
  65. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_agent_inboxes.py +0 -0
  66. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_agreements.py +0 -0
  67. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_diagnostics.py +0 -0
  68. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_events_webhooks.py +0 -0
  69. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_exports.py +0 -0
  70. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_inbox_webhooks.py +0 -0
  71. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_mailboxes.py +0 -0
  72. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_platform.py +0 -0
  73. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_simulation.py +0 -0
  74. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_subscribers.py +0 -0
  75. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_team_inboxes.py +0 -0
  76. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_mail_tracking.py +0 -0
  77. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_partner.py +0 -0
  78. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_support_actions.py +0 -0
  79. {stackshift-1.8.0 → stackshift-1.9.0}/tests/test_teams.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stackshift
3
- Version: 1.8.0
3
+ Version: 1.9.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,21 @@ 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
+ spec = computer.attach_agent_file("./spec.md")
191
+ conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
192
+ computer.agent_result(conversation["id"], wait=True)
193
+ computer.agent_turns(limit=20)
194
+
195
+ fanout = computer.prompt_agent(prompts=["fix it with a retry", "fix it with a lock"], provider="codex")
196
+ done = computer.agent_fanout(fanout["id"])
197
+ computer.keep_agent_fork(fanout["id"], done["forks"][0]["computer_id"])
198
+ computer.agent_fanouts()
199
+ ```
200
+
184
201
  `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
202
 
186
203
  An agent can get its own key without any existing key. The functions below send no `Authorization` header:
@@ -1,15 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: stackshift
3
- Version: 1.8.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.
@@ -51,6 +39,8 @@ computer.files.remove("app/tmp", recursive=True)
51
39
 
52
40
  `upload_dir` skips `.gitignore`d files in a git folder unless you pass `include_ignored=True`, and keeps modes, symlinks and modification times.
53
41
 
42
+ `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.
43
+
54
44
  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
45
 
56
46
  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 +171,21 @@ computer.agent_conversations()
181
171
  computer.agent_events(conversation["id"], after_seq=10, limit=50)
182
172
  ```
183
173
 
174
+ Providers are `COMPUTER_AGENT_PROVIDERS` (`claude`, `codex`, `gemini`, `opencode`, `cursor`, `copilot`, `amp`, `qwen`). Attach files, read the result, and try one task several ways:
175
+
176
+ ```python
177
+ computer.agent_providers()
178
+ spec = computer.attach_agent_file("./spec.md")
179
+ conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
180
+ computer.agent_result(conversation["id"], wait=True)
181
+ computer.agent_turns(limit=20)
182
+
183
+ fanout = computer.prompt_agent(prompts=["fix it with a retry", "fix it with a lock"], provider="codex")
184
+ done = computer.agent_fanout(fanout["id"])
185
+ computer.keep_agent_fork(fanout["id"], done["forks"][0]["computer_id"])
186
+ computer.agent_fanouts()
187
+ ```
188
+
184
189
  `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
190
 
186
191
  An agent can get its own key without any existing key. The functions below send no `Authorization` header:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "stackshift"
7
- version = "1.8.0"
7
+ version = "1.9.0"
8
8
  description = "Official Python SDK for StackShift."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -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,
@@ -59,6 +59,7 @@ from .workload_security import WorkloadSecurityClient
59
59
 
60
60
  __all__ = [
61
61
  "StackShift",
62
+ "COMPUTER_AGENT_PROVIDERS",
62
63
  "COMPUTER_CAPACITY_BUSY",
63
64
  "COMPUTER_LIMIT_EXCEEDED",
64
65
  "COMPUTER_SPEND_CAP_REACHED",
@@ -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,33 @@ 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
- optional = {"conversation_id": conversation_id, "provider": provider, "model": model, "cwd": cwd, "env": env, "secret_binding_ids": secret_binding_ids}
372
- return self._client.request("POST", f"/computers/{_seg(computer_id)}/agent/prompt", json={"prompt": prompt, **{key: value for key, value in optional.items() if value is not None}})
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_result(self, computer_id: str, conversation_id: str, *, wait: bool = False) -> dict[str, Any]:
390
+ 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
+
392
+ def agent_turns(self, computer_id: str, *, limit: int | None = None) -> list[dict[str, Any]]:
393
+ return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/turns", params=_params(limit=limit))["turns"]
394
+
395
+ def agent_fanouts(self, computer_id: str) -> list[dict[str, Any]]:
396
+ return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/fanouts")["fanouts"]
397
+
398
+ def agent_fanout(self, computer_id: str, fanout_id: str) -> dict[str, Any]:
399
+ return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/fanouts/{_seg(fanout_id)}")
400
+
401
+ def keep_agent_fork(self, computer_id: str, fanout_id: str, fork_computer_id: str) -> dict[str, Any]:
402
+ return self._client.request("POST", f"/computers/{_seg(computer_id)}/agent/fanouts/{_seg(fanout_id)}/keep", json={"computer_id": fork_computer_id})
373
403
 
374
404
  def agent_conversations(self, computer_id: str) -> list[dict[str, Any]]:
375
405
  return self._client.request("GET", f"/computers/{_seg(computer_id)}/agent/conversations")["conversations"]
@@ -835,9 +865,30 @@ class Computer:
835
865
  def revoke_ssh_tokens(self) -> None:
836
866
  self._client.revoke_ssh_tokens(self.id)
837
867
 
838
- def prompt_agent(self, prompt: str, **options: Any) -> dict[str, Any]:
868
+ def prompt_agent(self, prompt: str | None = None, **options: Any) -> dict[str, Any]:
839
869
  return self._client.prompt_agent(self.id, prompt, **options)
840
870
 
871
+ def attach_agent_file(self, local_path: str) -> str:
872
+ return self._client.attach_agent_file(self.id, local_path)
873
+
874
+ def agent_providers(self, *, refresh: bool = False) -> list[dict[str, Any]]:
875
+ return self._client.agent_providers(self.id, refresh=refresh)
876
+
877
+ def agent_result(self, conversation_id: str, *, wait: bool = False) -> dict[str, Any]:
878
+ return self._client.agent_result(self.id, conversation_id, wait=wait)
879
+
880
+ def agent_turns(self, *, limit: int | None = None) -> list[dict[str, Any]]:
881
+ return self._client.agent_turns(self.id, limit=limit)
882
+
883
+ def agent_fanouts(self) -> list[dict[str, Any]]:
884
+ return self._client.agent_fanouts(self.id)
885
+
886
+ def agent_fanout(self, fanout_id: str) -> dict[str, Any]:
887
+ return self._client.agent_fanout(self.id, fanout_id)
888
+
889
+ def keep_agent_fork(self, fanout_id: str, fork_computer_id: str) -> dict[str, Any]:
890
+ return self._client.keep_agent_fork(self.id, fanout_id, fork_computer_id)
891
+
841
892
  def agent_conversations(self) -> list[dict[str, Any]]:
842
893
  return self._client.agent_conversations(self.id)
843
894
 
@@ -1,3 +1,15 @@
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
+
1
13
  # StackShift Python SDK
2
14
 
3
15
  Official Python SDK for StackShift.
@@ -39,6 +51,8 @@ computer.files.remove("app/tmp", recursive=True)
39
51
 
40
52
  `upload_dir` skips `.gitignore`d files in a git folder unless you pass `include_ignored=True`, and keeps modes, symlinks and modification times.
41
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
+
42
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.
43
57
 
44
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.
@@ -169,6 +183,21 @@ computer.agent_conversations()
169
183
  computer.agent_events(conversation["id"], after_seq=10, limit=50)
170
184
  ```
171
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
+ spec = computer.attach_agent_file("./spec.md")
191
+ conversation = computer.prompt_agent("fix the failing tests", provider="claude", attachments=[spec])
192
+ computer.agent_result(conversation["id"], wait=True)
193
+ computer.agent_turns(limit=20)
194
+
195
+ fanout = computer.prompt_agent(prompts=["fix it with a retry", "fix it with a lock"], provider="codex")
196
+ done = computer.agent_fanout(fanout["id"])
197
+ computer.keep_agent_fork(fanout["id"], done["forks"][0]["computer_id"])
198
+ computer.agent_fanouts()
199
+ ```
200
+
172
201
  `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)`.
173
202
 
174
203
  An agent can get its own key without any existing key. The functions below send no `Authorization` header:
@@ -53,6 +53,7 @@ tests/test_assets_platform.py
53
53
  tests/test_assets_workflows.py
54
54
  tests/test_computers.py
55
55
  tests/test_computers_adapters.py
56
+ tests/test_computers_agent.py
56
57
  tests/test_computers_controls.py
57
58
  tests/test_computers_routes.py
58
59
  tests/test_databases.py
@@ -0,0 +1,76 @@
1
+ import os
2
+ import re
3
+ import tempfile
4
+ import unittest
5
+ from urllib.parse import urlparse
6
+
7
+ from stackshift import COMPUTER_AGENT_PROVIDERS, StackShift
8
+
9
+ from computers_mock import Response
10
+
11
+ ID = "11111111-1111-4111-8111-111111111111"
12
+ BASE = f"/computers/{ID}/agent"
13
+
14
+
15
+ class Recorder:
16
+ def __init__(self):
17
+ self.calls = []
18
+
19
+ def request(self, method, url, headers=None, params=None, json=None, data=None, stream=False, **_):
20
+ self.calls.append({"method": method, "path": re.sub(r"^/api/v1", "", urlparse(url).path), "params": params, "json": json})
21
+ return Response(200, {"providers": [], "fanouts": [], "forks": [], "turns": []})
22
+
23
+
24
+ class ComputerAgentTests(unittest.TestCase):
25
+ def setUp(self):
26
+ self.recorder = Recorder()
27
+ self.computer = StackShift(api_key="csk_fixture", session=self.recorder).computers.use(ID)
28
+
29
+ def last(self):
30
+ return self.recorder.calls[-1]
31
+
32
+ def test_ensure_project_posts_without_a_body(self):
33
+ self.computer._client.ensure_project()
34
+ self.assertEqual((self.last()["method"], self.last()["path"], self.last()["json"]), ("POST", "/computers/project", None))
35
+
36
+ def test_providers_constant(self):
37
+ self.assertEqual(COMPUTER_AGENT_PROVIDERS, ("claude", "codex", "gemini", "opencode", "cursor", "copilot", "amp", "qwen"))
38
+
39
+ def test_prompt_with_attachments_forks_and_prompts(self):
40
+ self.computer.prompt_agent("fix", provider="gemini", attachments=["/workspace/.stackshift/attachments/a/b.png"])
41
+ self.assertEqual((self.last()["method"], self.last()["path"]), ("POST", f"{BASE}/prompt"))
42
+ self.assertEqual(self.last()["json"], {"prompt": "fix", "provider": "gemini", "attachments": ["/workspace/.stackshift/attachments/a/b.png"]})
43
+ self.computer.prompt_agent(prompts=["a", "b"], provider="codex")
44
+ self.assertEqual(self.last()["json"], {"prompts": ["a", "b"], "provider": "codex"})
45
+ self.computer.prompt_agent("x", forks=3)
46
+ self.assertEqual(self.last()["json"], {"prompt": "x", "forks": 3})
47
+
48
+ def test_providers_result_and_fanouts(self):
49
+ self.computer.agent_providers()
50
+ self.assertEqual((self.last()["method"], self.last()["path"], self.last()["params"]), ("GET", f"{BASE}/providers", None))
51
+ self.computer.agent_providers(refresh=True)
52
+ self.assertEqual(self.last()["params"], {"refresh": "1"})
53
+ self.computer.agent_result("k1", wait=True)
54
+ self.assertEqual((self.last()["path"], self.last()["params"]), (f"{BASE}/conversations/k1/result", {"wait": "1"}))
55
+ self.computer.agent_turns(limit=20)
56
+ self.assertEqual((self.last()["path"], self.last()["params"]), (f"{BASE}/turns", {"limit": 20}))
57
+ self.computer.agent_fanouts()
58
+ self.assertEqual((self.last()["method"], self.last()["path"]), ("GET", f"{BASE}/fanouts"))
59
+ self.computer.agent_fanout("f1")
60
+ self.assertEqual(self.last()["path"], f"{BASE}/fanouts/f1")
61
+ self.computer.keep_agent_fork("f1", "fork1")
62
+ self.assertEqual((self.last()["method"], self.last()["path"], self.last()["json"]), ("POST", f"{BASE}/fanouts/f1/keep", {"computer_id": "fork1"}))
63
+
64
+ def test_attach_uploads_under_the_attachments_folder(self):
65
+ with tempfile.TemporaryDirectory() as folder:
66
+ path = os.path.join(folder, "spec.md")
67
+ open(path, "w").write("hello")
68
+ remote = self.computer.attach_agent_file(path)
69
+ self.assertRegex(remote, r"^/workspace/\.stackshift/attachments/[0-9a-f]+/spec\.md$")
70
+ put = next(call for call in self.recorder.calls if call["method"] == "PUT")
71
+ self.assertEqual(put["path"], f"/computers/{ID}/files")
72
+ self.assertEqual(put["params"]["path"], remote)
73
+
74
+
75
+ if __name__ == "__main__":
76
+ unittest.main()
@@ -23,7 +23,7 @@ PROJECT = "3f0c6a52-7d1e-4f53-9a3c-0d2b7f8e1a44"
23
23
  TEAM = "55555555-5555-4555-8555-555555555555"
24
24
  SSE = ["event: end", 'data: {"seq": 1}', ""]
25
25
  BENIGN = {
26
- "items": [], "conversations": [], "labels": [], "windows": [], "processes": [], "entries": [], "steps": [], "computer": {"id": ID, "state": "running"},
26
+ "items": [], "conversations": [], "providers": [], "fanouts": [], "turns": [], "labels": [], "windows": [], "processes": [], "entries": [], "steps": [], "computer": {"id": ID, "state": "running"},
27
27
  "forks": [], "results": [], "transfer": {"id": "t1"}, "ngn": {}, "usd": {}, "free_plan": {}, "running_limits": [], "id": "x",
28
28
  }
29
29
 
@@ -71,6 +71,7 @@ def table(sdk, computer):
71
71
  "listComputerSnapshots": lambda r: c.snapshots.list(PROJECT),
72
72
  "deleteComputerSnapshot": lambda r: c.snapshots.delete("s1"),
73
73
  "createComputerSSHCertificate": lambda r: c.ssh_certificate(ID, "ssh-ed25519 AAAA"),
74
+ "ensureComputerProject": lambda r: c.ensure_project(),
74
75
  "listComputerTemplates": lambda r: c.templates(PROJECT),
75
76
  "getComputerUsage": lambda r: c.usage(PROJECT),
76
77
  "deleteComputer": lambda r: computer.delete(),
@@ -85,6 +86,12 @@ def table(sdk, computer):
85
86
  "interruptComputerAgent": lambda r: computer.interrupt_agent("conv1"),
86
87
  "steerComputerAgent": lambda r: computer.steer_agent("conv1", "stop"),
87
88
  "promptComputerAgent": lambda r: computer.prompt_agent("fix it"),
89
+ "listComputerAgentProviders": lambda r: computer.agent_providers(),
90
+ "getComputerAgentResult": lambda r: computer.agent_result("conv1"),
91
+ "listComputerAgentTurns": lambda r: computer.agent_turns(),
92
+ "listComputerAgentFanouts": lambda r: computer.agent_fanouts(),
93
+ "getComputerAgentFanout": lambda r: computer.agent_fanout("fan1"),
94
+ "keepComputerAgentFork": lambda r: computer.keep_agent_fork("fan1", ID),
88
95
  "listComputerApprovals": lambda r: computer.approvals(),
89
96
  "askComputerOwner": lambda r: c.ask_owner(ID, "ok?", kind="help"),
90
97
  "sendComputerCommandStdin": lambda r: computer.send_stdin("cmd1", "yes\n"),
File without changes