Skip to content

Commit d215ac1

Browse files
feat: [Artifacts] public API file artifact downloads
1 parent 3706e8d commit d215ac1

File tree

6 files changed

+126
-29
lines changed

6 files changed

+126
-29
lines changed

.stats.yml

Lines changed: 2 additions & 2 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-d57dae004e23149ddae4bd26e3ba05c2378d2c1070df0f303b19e45111c780d5.yml
3-
openapi_spec_hash: 6a15b456e6520a79981fafed3b0c94b9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-a29592b2ba26cba9d89b95969d66506f49c08e140b76ce4aea4189e5c1dccc06.yml
3+
openapi_spec_hash: 27a5de1f891104d5e47904ad8e4b4bd1
44
config_hash: 40327fb76b7cce7b97f23de9b8d48efb

src/oz_agent_sdk/resources/agent/agent.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Iterable
5+
from typing import Any, Iterable, cast
66
from typing_extensions import Literal
77

88
import httpx
@@ -163,8 +163,8 @@ def get_artifact(
163163
) -> AgentGetArtifactResponse:
164164
"""Retrieve an artifact by its UUID.
165165
166-
For screenshot artifacts, returns a
167-
time-limited signed download URL.
166+
For supported downloadable artifacts, returns
167+
a time-limited signed download URL.
168168
169169
Args:
170170
extra_headers: Send extra headers
@@ -177,12 +177,17 @@ def get_artifact(
177177
"""
178178
if not artifact_uid:
179179
raise ValueError(f"Expected a non-empty value for `artifact_uid` but received {artifact_uid!r}")
180-
return self._get(
181-
path_template("/agent/artifacts/{artifact_uid}", artifact_uid=artifact_uid),
182-
options=make_request_options(
183-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
180+
return cast(
181+
AgentGetArtifactResponse,
182+
self._get(
183+
path_template("/agent/artifacts/{artifact_uid}", artifact_uid=artifact_uid),
184+
options=make_request_options(
185+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
186+
),
187+
cast_to=cast(
188+
Any, AgentGetArtifactResponse
189+
), # Union types cannot be passed in as arguments in the type system
184190
),
185-
cast_to=AgentGetArtifactResponse,
186191
)
187192

188193
def run(
@@ -382,8 +387,8 @@ async def get_artifact(
382387
) -> AgentGetArtifactResponse:
383388
"""Retrieve an artifact by its UUID.
384389
385-
For screenshot artifacts, returns a
386-
time-limited signed download URL.
390+
For supported downloadable artifacts, returns
391+
a time-limited signed download URL.
387392
388393
Args:
389394
extra_headers: Send extra headers
@@ -396,12 +401,17 @@ async def get_artifact(
396401
"""
397402
if not artifact_uid:
398403
raise ValueError(f"Expected a non-empty value for `artifact_uid` but received {artifact_uid!r}")
399-
return await self._get(
400-
path_template("/agent/artifacts/{artifact_uid}", artifact_uid=artifact_uid),
401-
options=make_request_options(
402-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
404+
return cast(
405+
AgentGetArtifactResponse,
406+
await self._get(
407+
path_template("/agent/artifacts/{artifact_uid}", artifact_uid=artifact_uid),
408+
options=make_request_options(
409+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
410+
),
411+
cast_to=cast(
412+
Any, AgentGetArtifactResponse
413+
), # Union types cannot be passed in as arguments in the type system
403414
),
404-
cast_to=AgentGetArtifactResponse,
405415
)
406416

407417
async def run(

src/oz_agent_sdk/resources/agent/runs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def retrieve(
8787
def list(
8888
self,
8989
*,
90-
artifact_type: Literal["PLAN", "PULL_REQUEST", "SCREENSHOT"] | Omit = omit,
90+
artifact_type: Literal["PLAN", "PULL_REQUEST", "SCREENSHOT", "FILE"] | Omit = omit,
9191
created_after: Union[str, datetime] | Omit = omit,
9292
created_before: Union[str, datetime] | Omit = omit,
9393
creator: str | Omit = omit,
@@ -307,7 +307,7 @@ async def retrieve(
307307
def list(
308308
self,
309309
*,
310-
artifact_type: Literal["PLAN", "PULL_REQUEST", "SCREENSHOT"] | Omit = omit,
310+
artifact_type: Literal["PLAN", "PULL_REQUEST", "SCREENSHOT", "FILE"] | Omit = omit,
311311
created_after: Union[str, datetime] | Omit = omit,
312312
created_before: Union[str, datetime] | Omit = omit,
313313
creator: str | Omit = omit,

src/oz_agent_sdk/types/agent/artifact_item.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"PullRequestArtifactData",
1616
"ScreenshotArtifact",
1717
"ScreenshotArtifactData",
18+
"FileArtifact",
19+
"FileArtifactData",
1820
]
1921

2022

@@ -78,6 +80,37 @@ class ScreenshotArtifact(BaseModel):
7880
data: ScreenshotArtifactData
7981

8082

83+
class FileArtifactData(BaseModel):
84+
artifact_uid: str
85+
"""Unique identifier for the file artifact"""
86+
87+
filename: str
88+
"""Last path component of filepath"""
89+
90+
filepath: str
91+
"""Conversation-relative filepath for the uploaded file"""
92+
93+
mime_type: str
94+
"""MIME type of the uploaded file"""
95+
96+
description: Optional[str] = None
97+
"""Optional description of the file"""
98+
99+
size_bytes: Optional[int] = None
100+
"""Size of the uploaded file in bytes"""
101+
102+
103+
class FileArtifact(BaseModel):
104+
artifact_type: Literal["FILE"]
105+
"""Type of the artifact"""
106+
107+
created_at: datetime
108+
"""Timestamp when the artifact was created (RFC3339)"""
109+
110+
data: FileArtifactData
111+
112+
81113
ArtifactItem: TypeAlias = Annotated[
82-
Union[PlanArtifact, PullRequestArtifact, ScreenshotArtifact], PropertyInfo(discriminator="artifact_type")
114+
Union[PlanArtifact, PullRequestArtifact, ScreenshotArtifact, FileArtifact],
115+
PropertyInfo(discriminator="artifact_type"),
83116
]

src/oz_agent_sdk/types/agent/run_list_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class RunListParams(TypedDict, total=False):
17-
artifact_type: Literal["PLAN", "PULL_REQUEST", "SCREENSHOT"]
17+
artifact_type: Literal["PLAN", "PULL_REQUEST", "SCREENSHOT", "FILE"]
1818
"""Filter runs by artifact type"""
1919

2020
created_after: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import Union, Optional
44
from datetime import datetime
5+
from typing_extensions import Literal, Annotated, TypeAlias
56

7+
from .._utils import PropertyInfo
68
from .._models import BaseModel
79

8-
__all__ = ["AgentGetArtifactResponse", "Data"]
10+
__all__ = [
11+
"AgentGetArtifactResponse",
12+
"ScreenshotArtifactResponse",
13+
"ScreenshotArtifactResponseData",
14+
"FileArtifactResponse",
15+
"FileArtifactResponseData",
16+
]
917

1018

11-
class Data(BaseModel):
19+
class ScreenshotArtifactResponseData(BaseModel):
1220
"""Response data for a screenshot artifact, including a signed download URL."""
1321

1422
content_type: str
@@ -24,17 +32,63 @@ class Data(BaseModel):
2432
"""Optional description of the screenshot"""
2533

2634

27-
class AgentGetArtifactResponse(BaseModel):
28-
"""Response for artifact retrieval. Currently supports screenshot artifacts."""
35+
class ScreenshotArtifactResponse(BaseModel):
36+
"""Response for retrieving a screenshot artifact."""
2937

30-
artifact_type: str
31-
"""Type of the artifact (e.g., SCREENSHOT)"""
38+
artifact_type: Literal["SCREENSHOT"]
39+
"""Type of the artifact"""
3240

3341
artifact_uid: str
3442
"""Unique identifier (UUID) for the artifact"""
3543

3644
created_at: datetime
3745
"""Timestamp when the artifact was created (RFC3339)"""
3846

39-
data: Data
47+
data: ScreenshotArtifactResponseData
4048
"""Response data for a screenshot artifact, including a signed download URL."""
49+
50+
51+
class FileArtifactResponseData(BaseModel):
52+
"""Response data for a file artifact, including a signed download URL."""
53+
54+
content_type: str
55+
"""MIME type of the uploaded file"""
56+
57+
download_url: str
58+
"""Time-limited signed URL to download the file"""
59+
60+
expires_at: datetime
61+
"""Timestamp when the download URL expires (RFC3339)"""
62+
63+
filename: str
64+
"""Last path component of filepath"""
65+
66+
filepath: str
67+
"""Conversation-relative filepath for the uploaded file"""
68+
69+
description: Optional[str] = None
70+
"""Optional description of the file"""
71+
72+
size_bytes: Optional[int] = None
73+
"""Size of the uploaded file in bytes"""
74+
75+
76+
class FileArtifactResponse(BaseModel):
77+
"""Response for retrieving a file artifact."""
78+
79+
artifact_type: Literal["FILE"]
80+
"""Type of the artifact"""
81+
82+
artifact_uid: str
83+
"""Unique identifier (UUID) for the artifact"""
84+
85+
created_at: datetime
86+
"""Timestamp when the artifact was created (RFC3339)"""
87+
88+
data: FileArtifactResponseData
89+
"""Response data for a file artifact, including a signed download URL."""
90+
91+
92+
AgentGetArtifactResponse: TypeAlias = Annotated[
93+
Union[ScreenshotArtifactResponse, FileArtifactResponse], PropertyInfo(discriminator="artifact_type")
94+
]

0 commit comments

Comments
 (0)