Skip to content

Commit 0cc041e

Browse files
feat(api): sorting
1 parent 9766f85 commit 0cc041e

File tree

12 files changed

+85
-138
lines changed

12 files changed

+85
-138
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-39e18bbb8b0af73eca7a880f56afbdecd69e3e5bab82a04c4d6429c32d7e6727.yml
3-
openapi_spec_hash: 7a0de988bb37416d6e80f4a4bbe9d0d0
4-
config_hash: 38ab203e1bd97a9bb22bbf744bcb5808
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-a368122275968e270e3e786e6cf176ae87aa56ef85e3270ed59da99c87996dc8.yml
3+
openapi_spec_hash: 86cab7da7cb620fc90482f50d92acf70
4+
config_hash: 25c1059aa958c8c2ad60ef16c318514d

api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ from oz_agent_sdk.types import (
77
AgentSkill,
88
AmbientAgentConfig,
99
CloudEnvironmentConfig,
10-
Error,
11-
ErrorCode,
1210
McpServerConfig,
13-
Scope,
1411
UserProfile,
1512
AgentListResponse,
1613
AgentGetArtifactResponse,
@@ -51,7 +48,6 @@ Types:
5148

5249
```python
5350
from oz_agent_sdk.types.agent import (
54-
ScheduledAgentHistoryItem,
5551
ScheduledAgentItem,
5652
ScheduleListResponse,
5753
ScheduleDeleteResponse,

src/oz_agent_sdk/resources/agent/runs.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def list(
100100
schedule_id: str | Omit = omit,
101101
skill: str | Omit = omit,
102102
skill_spec: str | Omit = omit,
103+
sort_by: Literal["updated_at", "created_at", "title", "agent"] | Omit = omit,
104+
sort_order: Literal["asc", "desc"] | Omit = omit,
103105
source: RunSourceType | Omit = omit,
104106
state: List[RunState] | Omit = omit,
105107
updated_after: Union[str, datetime] | Omit = omit,
@@ -112,8 +114,8 @@ def list(
112114
) -> RunListResponse:
113115
"""Retrieve a paginated list of agent runs with optional filtering.
114116
115-
Results are
116-
ordered by creation time (newest first).
117+
Results default
118+
to `sort_by=updated_at` and `sort_order=desc`.
117119
118120
Args:
119121
artifact_type: Filter runs by artifact type (PLAN or PULL_REQUEST)
@@ -143,6 +145,15 @@ def list(
143145
144146
skill_spec: Filter runs by skill spec (e.g., "owner/repo:path/to/SKILL.md")
145147
148+
sort_by: Sort field for results.
149+
150+
- `updated_at`: Sort by last update timestamp (default)
151+
- `created_at`: Sort by creation timestamp
152+
- `title`: Sort alphabetically by run title
153+
- `agent`: Sort alphabetically by skill. Runs without a skill are grouped last.
154+
155+
sort_order: Sort direction
156+
146157
source: Filter by run source type
147158
148159
state: Filter by run state. Can be specified multiple times to match any of the given
@@ -180,6 +191,8 @@ def list(
180191
"schedule_id": schedule_id,
181192
"skill": skill,
182193
"skill_spec": skill_spec,
194+
"sort_by": sort_by,
195+
"sort_order": sort_order,
183196
"source": source,
184197
"state": state,
185198
"updated_after": updated_after,
@@ -204,11 +217,7 @@ def cancel(
204217
"""Cancel an agent run that is currently queued or in progress.
205218
206219
Once cancelled, the
207-
run will transition to a cancelled state.
208-
209-
Not all runs can be cancelled. Runs that are in a terminal state (SUCCEEDED,
210-
FAILED, ERROR, BLOCKED, CANCELLED) return 400. Runs in PENDING state return 409
211-
(retry after a moment). Self-hosted, local, and GitHub Action runs return 422.
220+
run will transition to a failed state.
212221
213222
Args:
214223
extra_headers: Send extra headers
@@ -302,6 +311,8 @@ async def list(
302311
schedule_id: str | Omit = omit,
303312
skill: str | Omit = omit,
304313
skill_spec: str | Omit = omit,
314+
sort_by: Literal["updated_at", "created_at", "title", "agent"] | Omit = omit,
315+
sort_order: Literal["asc", "desc"] | Omit = omit,
305316
source: RunSourceType | Omit = omit,
306317
state: List[RunState] | Omit = omit,
307318
updated_after: Union[str, datetime] | Omit = omit,
@@ -314,8 +325,8 @@ async def list(
314325
) -> RunListResponse:
315326
"""Retrieve a paginated list of agent runs with optional filtering.
316327
317-
Results are
318-
ordered by creation time (newest first).
328+
Results default
329+
to `sort_by=updated_at` and `sort_order=desc`.
319330
320331
Args:
321332
artifact_type: Filter runs by artifact type (PLAN or PULL_REQUEST)
@@ -345,6 +356,15 @@ async def list(
345356
346357
skill_spec: Filter runs by skill spec (e.g., "owner/repo:path/to/SKILL.md")
347358
359+
sort_by: Sort field for results.
360+
361+
- `updated_at`: Sort by last update timestamp (default)
362+
- `created_at`: Sort by creation timestamp
363+
- `title`: Sort alphabetically by run title
364+
- `agent`: Sort alphabetically by skill. Runs without a skill are grouped last.
365+
366+
sort_order: Sort direction
367+
348368
source: Filter by run source type
349369
350370
state: Filter by run state. Can be specified multiple times to match any of the given
@@ -382,6 +402,8 @@ async def list(
382402
"schedule_id": schedule_id,
383403
"skill": skill,
384404
"skill_spec": skill_spec,
405+
"sort_by": sort_by,
406+
"sort_order": sort_order,
385407
"source": source,
386408
"state": state,
387409
"updated_after": updated_after,
@@ -406,11 +428,7 @@ async def cancel(
406428
"""Cancel an agent run that is currently queued or in progress.
407429
408430
Once cancelled, the
409-
run will transition to a cancelled state.
410-
411-
Not all runs can be cancelled. Runs that are in a terminal state (SUCCEEDED,
412-
FAILED, ERROR, BLOCKED, CANCELLED) return 400. Runs in PENDING state return 409
413-
(retry after a moment). Self-hosted, local, and GitHub Action runs return 422.
431+
run will transition to a failed state.
414432
415433
Args:
416434
extra_headers: Send extra headers

src/oz_agent_sdk/types/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import annotations
44

5-
from .scope import Scope as Scope
6-
from .error_code import ErrorCode as ErrorCode
75
from .agent_skill import AgentSkill as AgentSkill
86
from .user_profile import UserProfile as UserProfile
97
from .agent_run_params import AgentRunParams as AgentRunParams

src/oz_agent_sdk/types/agent/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
from .schedule_list_response import ScheduleListResponse as ScheduleListResponse
1515
from .schedule_update_params import ScheduleUpdateParams as ScheduleUpdateParams
1616
from .schedule_delete_response import ScheduleDeleteResponse as ScheduleDeleteResponse
17-
from .scheduled_agent_history_item import ScheduledAgentHistoryItem as ScheduledAgentHistoryItem
1817
from .session_check_redirect_response import SessionCheckRedirectResponse as SessionCheckRedirectResponse

src/oz_agent_sdk/types/agent/run_item.py

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
from typing import List, Optional
44
from datetime import datetime
5+
from typing_extensions import Literal
56

6-
from ..scope import Scope
77
from ..._models import BaseModel
88
from .run_state import RunState
9-
from ..error_code import ErrorCode
109
from ..user_profile import UserProfile
1110
from .artifact_item import ArtifactItem
1211
from .run_source_type import RunSourceType
1312
from ..ambient_agent_config import AmbientAgentConfig
1413

15-
__all__ = ["RunItem", "AgentSkill", "RequestUsage", "Schedule", "StatusMessage"]
14+
__all__ = ["RunItem", "AgentSkill", "RequestUsage", "Schedule", "Scope", "StatusMessage"]
1615

1716

1817
class AgentSkill(BaseModel):
@@ -59,52 +58,19 @@ class Schedule(BaseModel):
5958
"""Name of the schedule at the time the run was created"""
6059

6160

62-
class StatusMessage(BaseModel):
63-
"""Status message for a run.
64-
65-
For terminal error states, includes structured
66-
error code and retryability info from the platform error catalog.
67-
"""
61+
class Scope(BaseModel):
62+
"""Ownership scope for a resource (team or personal)"""
6863

69-
message: str
70-
"""Human-readable status message"""
64+
type: Literal["User", "Team"]
65+
"""Type of ownership ("User" for personal, "Team" for team-owned)"""
7166

72-
error_code: Optional[ErrorCode] = None
73-
"""
74-
Machine-readable error code identifying the problem type. Used in the `type` URI
75-
of Error responses and in the `error_code` field of RunStatusMessage.
76-
77-
User errors (run transitions to FAILED):
78-
79-
- `insufficient_credits` — Team has no remaining add-on credits
80-
- `feature_not_available` — Required feature not enabled for user's plan
81-
- `external_authentication_required` — User hasn't authorized a required
82-
external service
83-
- `not_authorized` — Principal lacks permission for the requested operation
84-
- `invalid_request` — Request is malformed or contains invalid parameters
85-
- `resource_not_found` — Referenced resource does not exist
86-
- `budget_exceeded` — Spending budget limit has been reached
87-
- `integration_disabled` — Integration is disabled and must be enabled
88-
- `integration_not_configured` — Integration setup is incomplete
89-
- `operation_not_supported` — Requested operation not supported for this
90-
resource/state
91-
- `environment_setup_failed` — Client-side environment setup failed
92-
- `content_policy_violation` — Prompt or setup commands violated content policy
93-
- `conflict` — Request conflicts with the current state of the resource
94-
95-
Warp errors (run transitions to ERROR):
96-
97-
- `authentication_required` — Request lacks valid authentication credentials
98-
- `resource_unavailable` — Transient infrastructure issue (retryable)
99-
- `internal_error` — Unexpected server-side error (retryable)
100-
"""
67+
uid: Optional[str] = None
68+
"""UID of the owning user or team"""
10169

102-
retryable: Optional[bool] = None
103-
"""Whether the error is transient and the client may retry by submitting a new run.
10470

105-
Only present on terminal error states. When false, retrying without addressing
106-
the underlying cause will not succeed.
107-
"""
71+
class StatusMessage(BaseModel):
72+
message: Optional[str] = None
73+
"""Human-readable status message"""
10874

10975

11076
class RunItem(BaseModel):
@@ -199,8 +165,3 @@ class RunItem(BaseModel):
199165
"""Timestamp when the agent started working on the run (RFC3339)"""
200166

201167
status_message: Optional[StatusMessage] = None
202-
"""Status message for a run.
203-
204-
For terminal error states, includes structured error code and retryability info
205-
from the platform error catalog.
206-
"""

src/oz_agent_sdk/types/agent/run_list_params.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ class RunListParams(TypedDict, total=False):
5656
skill_spec: str
5757
"""Filter runs by skill spec (e.g., "owner/repo:path/to/SKILL.md")"""
5858

59+
sort_by: Literal["updated_at", "created_at", "title", "agent"]
60+
"""Sort field for results.
61+
62+
- `updated_at`: Sort by last update timestamp (default)
63+
- `created_at`: Sort by creation timestamp
64+
- `title`: Sort alphabetically by run title
65+
- `agent`: Sort alphabetically by skill. Runs without a skill are grouped last.
66+
"""
67+
68+
sort_order: Literal["asc", "desc"]
69+
"""Sort direction"""
70+
5971
source: RunSourceType
6072
"""Filter by run source type"""
6173

src/oz_agent_sdk/types/agent/scheduled_agent_history_item.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/oz_agent_sdk/types/agent/scheduled_agent_item.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,34 @@
22

33
from typing import Optional
44
from datetime import datetime
5+
from typing_extensions import Literal
56

6-
from ..scope import Scope
77
from ..._models import BaseModel
88
from ..user_profile import UserProfile
99
from ..ambient_agent_config import AmbientAgentConfig
1010
from ..cloud_environment_config import CloudEnvironmentConfig
11-
from .scheduled_agent_history_item import ScheduledAgentHistoryItem
1211

13-
__all__ = ["ScheduledAgentItem"]
12+
__all__ = ["ScheduledAgentItem", "History", "Scope"]
13+
14+
15+
class History(BaseModel):
16+
"""Scheduler-derived history metadata for a scheduled agent"""
17+
18+
last_ran: Optional[datetime] = None
19+
"""Timestamp of the last successful run (RFC3339)"""
20+
21+
next_run: Optional[datetime] = None
22+
"""Timestamp of the next scheduled run (RFC3339)"""
23+
24+
25+
class Scope(BaseModel):
26+
"""Ownership scope for a resource (team or personal)"""
27+
28+
type: Literal["User", "Team"]
29+
"""Type of ownership ("User" for personal, "Team" for team-owned)"""
30+
31+
uid: Optional[str] = None
32+
"""UID of the owning user or team"""
1433

1534

1635
class ScheduledAgentItem(BaseModel):
@@ -46,7 +65,7 @@ class ScheduledAgentItem(BaseModel):
4665
environment: Optional[CloudEnvironmentConfig] = None
4766
"""Configuration for a cloud environment used by scheduled agents"""
4867

49-
history: Optional[ScheduledAgentHistoryItem] = None
68+
history: Optional[History] = None
5069
"""Scheduler-derived history metadata for a scheduled agent"""
5170

5271
last_spawn_error: Optional[str] = None

src/oz_agent_sdk/types/error_code.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)