adcp 1.6.1__py3-none-any.whl → 2.0.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.
- adcp/__init__.py +19 -221
- adcp/adagents.py +11 -12
- adcp/client.py +16 -11
- adcp/types/generated.py +540 -1134
- adcp/types/generated_poc/__init__.py +3 -0
- adcp/types/generated_poc/activate_signal_request.py +34 -0
- adcp/types/generated_poc/activate_signal_response.py +57 -0
- adcp/types/generated_poc/activation_key.py +30 -0
- adcp/types/generated_poc/adagents.py +266 -0
- adcp/types/generated_poc/asset_type.py +100 -0
- adcp/types/generated_poc/audio_asset.py +26 -0
- adcp/types/generated_poc/brand_manifest.py +260 -0
- adcp/types/generated_poc/brand_manifest_ref.py +361 -0
- adcp/types/generated_poc/build_creative_request.py +43 -0
- adcp/types/generated_poc/build_creative_response.py +57 -0
- adcp/types/generated_poc/channels.py +19 -0
- adcp/types/generated_poc/cpc_option.py +39 -0
- adcp/types/generated_poc/cpcv_option.py +41 -0
- adcp/types/generated_poc/cpm_auction_option.py +54 -0
- adcp/types/generated_poc/cpm_fixed_option.py +39 -0
- adcp/types/generated_poc/cpp_option.py +60 -0
- adcp/types/generated_poc/cpv_option.py +73 -0
- adcp/types/generated_poc/create_media_buy_request.py +96 -0
- adcp/types/generated_poc/create_media_buy_response.py +66 -0
- adcp/types/generated_poc/creative_asset.py +83 -0
- adcp/types/generated_poc/creative_assignment.py +27 -0
- adcp/types/generated_poc/creative_manifest.py +61 -0
- adcp/types/generated_poc/creative_policy.py +34 -0
- adcp/types/generated_poc/creative_status.py +14 -0
- adcp/types/generated_poc/css_asset.py +20 -0
- adcp/types/generated_poc/daast_asset.py +76 -0
- adcp/types/generated_poc/delivery_metrics.py +111 -0
- adcp/types/generated_poc/delivery_type.py +12 -0
- adcp/types/generated_poc/deployment.py +78 -0
- adcp/types/generated_poc/destination.py +43 -0
- adcp/types/generated_poc/error.py +29 -0
- adcp/types/generated_poc/flat_rate_option.py +93 -0
- adcp/types/generated_poc/format.py +260 -0
- adcp/types/generated_poc/format_id.py +29 -0
- adcp/types/generated_poc/frequency_cap.py +19 -0
- adcp/types/generated_poc/frequency_cap_scope.py +16 -0
- adcp/types/generated_poc/get_media_buy_delivery_request.py +65 -0
- adcp/types/generated_poc/get_media_buy_delivery_response.py +220 -0
- adcp/types/generated_poc/get_products_request.py +83 -0
- adcp/types/generated_poc/get_products_response.py +29 -0
- adcp/types/generated_poc/get_signals_request.py +77 -0
- adcp/types/generated_poc/get_signals_response.py +65 -0
- adcp/types/generated_poc/html_asset.py +18 -0
- adcp/types/generated_poc/identifier_types.py +29 -0
- adcp/types/generated_poc/image_asset.py +23 -0
- adcp/types/generated_poc/index.py +17 -0
- adcp/types/generated_poc/javascript_asset.py +25 -0
- adcp/types/generated_poc/list_authorized_properties_request.py +39 -0
- adcp/types/generated_poc/list_authorized_properties_response.py +85 -0
- adcp/types/generated_poc/list_creative_formats_request.py +93 -0
- adcp/types/generated_poc/list_creative_formats_response.py +63 -0
- adcp/types/generated_poc/list_creatives_request.py +154 -0
- adcp/types/generated_poc/list_creatives_response.py +234 -0
- adcp/types/generated_poc/markdown_asset.py +43 -0
- adcp/types/generated_poc/measurement.py +40 -0
- adcp/types/generated_poc/media_buy.py +37 -0
- adcp/types/generated_poc/media_buy_status.py +14 -0
- adcp/types/generated_poc/pacing.py +13 -0
- adcp/types/generated_poc/package.py +61 -0
- adcp/types/generated_poc/package_request.py +61 -0
- adcp/types/generated_poc/package_status.py +14 -0
- adcp/types/generated_poc/performance_feedback.py +89 -0
- adcp/types/generated_poc/placement.py +37 -0
- adcp/types/generated_poc/preview_creative_request.py +163 -0
- adcp/types/generated_poc/preview_creative_response.py +175 -0
- adcp/types/generated_poc/preview_render.py +144 -0
- adcp/types/generated_poc/pricing_model.py +17 -0
- adcp/types/generated_poc/pricing_option.py +365 -0
- adcp/types/generated_poc/product.py +211 -0
- adcp/types/generated_poc/promoted_offerings.py +102 -0
- adcp/types/generated_poc/promoted_products.py +38 -0
- adcp/types/generated_poc/property.py +79 -0
- adcp/types/generated_poc/protocol_envelope.py +61 -0
- adcp/types/generated_poc/provide_performance_feedback_request.py +85 -0
- adcp/types/generated_poc/provide_performance_feedback_response.py +59 -0
- adcp/types/generated_poc/publisher_identifier_types.py +15 -0
- adcp/types/generated_poc/push_notification_config.py +55 -0
- adcp/types/generated_poc/reporting_capabilities.py +68 -0
- adcp/types/generated_poc/response.py +24 -0
- adcp/types/generated_poc/standard_format_ids.py +45 -0
- adcp/types/generated_poc/start_timing.py +13 -0
- adcp/types/generated_poc/sub_asset.py +55 -0
- adcp/types/generated_poc/sync_creatives_request.py +69 -0
- adcp/types/generated_poc/sync_creatives_response.py +117 -0
- adcp/types/generated_poc/targeting.py +53 -0
- adcp/types/generated_poc/task_status.py +19 -0
- adcp/types/generated_poc/task_type.py +15 -0
- adcp/types/generated_poc/tasks_get_request.py +29 -0
- adcp/types/generated_poc/tasks_get_response.py +112 -0
- adcp/types/generated_poc/tasks_list_request.py +121 -0
- adcp/types/generated_poc/tasks_list_response.py +122 -0
- adcp/types/generated_poc/text_asset.py +20 -0
- adcp/types/generated_poc/update_media_buy_request.py +160 -0
- adcp/types/generated_poc/update_media_buy_response.py +67 -0
- adcp/types/generated_poc/url_asset.py +33 -0
- adcp/types/generated_poc/vast_asset.py +86 -0
- adcp/types/generated_poc/vcpm_auction_option.py +57 -0
- adcp/types/generated_poc/vcpm_fixed_option.py +43 -0
- adcp/types/generated_poc/video_asset.py +28 -0
- adcp/types/generated_poc/webhook_asset.py +65 -0
- adcp/types/generated_poc/webhook_payload.py +102 -0
- adcp/utils/preview_cache.py +54 -41
- adcp/validation.py +172 -0
- {adcp-1.6.1.dist-info → adcp-2.0.0.dist-info}/METADATA +3 -1
- adcp-2.0.0.dist-info/RECORD +130 -0
- adcp/types/tasks.py +0 -511
- adcp-1.6.1.dist-info/RECORD +0 -28
- {adcp-1.6.1.dist-info → adcp-2.0.0.dist-info}/WHEEL +0 -0
- {adcp-1.6.1.dist-info → adcp-2.0.0.dist-info}/entry_points.txt +0 -0
- {adcp-1.6.1.dist-info → adcp-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {adcp-1.6.1.dist-info → adcp-2.0.0.dist-info}/top_level.txt +0 -0
adcp/__init__.py
CHANGED
|
@@ -48,122 +48,20 @@ from adcp.testing import (
|
|
|
48
48
|
test_agent_client,
|
|
49
49
|
test_agent_no_auth,
|
|
50
50
|
)
|
|
51
|
+
|
|
52
|
+
# Import all generated types - users can import what they need from adcp.types.generated
|
|
53
|
+
from adcp.types import generated
|
|
51
54
|
from adcp.types.core import AgentConfig, Protocol, TaskResult, TaskStatus, WebhookMetadata
|
|
52
|
-
from adcp.types.generated import
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
AgentDeployment,
|
|
60
|
-
AgentDestination,
|
|
61
|
-
BothPreviewRender,
|
|
62
|
-
# Brand types
|
|
63
|
-
BrandManifest,
|
|
64
|
-
BrandManifestRef,
|
|
65
|
-
BuildCreativeRequest,
|
|
66
|
-
BuildCreativeResponse,
|
|
67
|
-
# Channel types
|
|
68
|
-
Channels,
|
|
69
|
-
CreateMediaBuyError,
|
|
70
|
-
CreateMediaBuyRequest,
|
|
71
|
-
CreateMediaBuyResponse,
|
|
72
|
-
CreateMediaBuySuccess,
|
|
73
|
-
# Creative types
|
|
74
|
-
CreativeAsset,
|
|
75
|
-
CreativeAssignment,
|
|
76
|
-
CreativeManifest,
|
|
77
|
-
CreativePolicy,
|
|
78
|
-
DaastAsset,
|
|
79
|
-
# Metrics types
|
|
80
|
-
DeliveryMetrics,
|
|
81
|
-
# Delivery types
|
|
82
|
-
DeliveryType,
|
|
83
|
-
Deployment,
|
|
84
|
-
# Deployment types
|
|
85
|
-
Destination,
|
|
86
|
-
Error,
|
|
87
|
-
Format,
|
|
88
|
-
FormatId,
|
|
89
|
-
FrequencyCap,
|
|
90
|
-
GetMediaBuyDeliveryRequest,
|
|
91
|
-
GetMediaBuyDeliveryResponse,
|
|
92
|
-
GetProductsRequest,
|
|
93
|
-
GetProductsResponse,
|
|
94
|
-
GetSignalsRequest,
|
|
95
|
-
GetSignalsResponse,
|
|
96
|
-
HtmlPreviewRender,
|
|
97
|
-
InlineDaastAsset,
|
|
98
|
-
InlineVastAsset,
|
|
99
|
-
Key_valueActivationKey,
|
|
100
|
-
ListAuthorizedPropertiesRequest,
|
|
101
|
-
ListAuthorizedPropertiesResponse,
|
|
102
|
-
ListCreativeFormatsRequest,
|
|
103
|
-
ListCreativeFormatsResponse,
|
|
104
|
-
ListCreativesRequest,
|
|
105
|
-
ListCreativesResponse,
|
|
106
|
-
Measurement,
|
|
107
|
-
# Core domain types
|
|
108
|
-
MediaBuy,
|
|
109
|
-
# Status enums
|
|
110
|
-
MediaBuyStatus,
|
|
111
|
-
# Sub-asset types
|
|
112
|
-
MediaSubAsset,
|
|
113
|
-
Pacing,
|
|
114
|
-
Package,
|
|
115
|
-
PackageStatus,
|
|
116
|
-
PerformanceFeedback,
|
|
117
|
-
Placement,
|
|
118
|
-
PlatformDeployment,
|
|
119
|
-
PlatformDestination,
|
|
120
|
-
PreviewCreativeRequest,
|
|
121
|
-
PreviewCreativeResponse,
|
|
122
|
-
# Preview render types
|
|
123
|
-
PreviewRender,
|
|
124
|
-
PricingModel,
|
|
125
|
-
# Pricing types
|
|
126
|
-
PricingOption,
|
|
127
|
-
Product,
|
|
128
|
-
PromotedProducts,
|
|
129
|
-
# Property and placement types
|
|
130
|
-
Property,
|
|
131
|
-
ProtocolEnvelope,
|
|
132
|
-
ProvidePerformanceFeedbackRequest,
|
|
133
|
-
ProvidePerformanceFeedbackResponse,
|
|
134
|
-
PushNotificationConfig,
|
|
135
|
-
ReportingCapabilities,
|
|
136
|
-
Response,
|
|
137
|
-
Segment_idActivationKey,
|
|
138
|
-
StandardFormatIds,
|
|
139
|
-
StartTiming,
|
|
140
|
-
SubAsset,
|
|
141
|
-
SyncCreativesError,
|
|
142
|
-
SyncCreativesRequest,
|
|
143
|
-
SyncCreativesResponse,
|
|
144
|
-
SyncCreativesSuccess,
|
|
145
|
-
# Targeting types
|
|
146
|
-
Targeting,
|
|
147
|
-
# Task types
|
|
148
|
-
TaskType,
|
|
149
|
-
TextSubAsset,
|
|
150
|
-
UpdateMediaBuyError,
|
|
151
|
-
UpdateMediaBuyRequest,
|
|
152
|
-
UpdateMediaBuyResponse,
|
|
153
|
-
UpdateMediaBuySuccess,
|
|
154
|
-
UrlDaastAsset,
|
|
155
|
-
UrlPreviewRender,
|
|
156
|
-
UrlVastAsset,
|
|
157
|
-
# Asset delivery types (VAST/DAAST)
|
|
158
|
-
VastAsset,
|
|
159
|
-
# Protocol types
|
|
160
|
-
WebhookPayload,
|
|
161
|
-
)
|
|
162
|
-
from adcp.types.generated import (
|
|
163
|
-
TaskStatus as GeneratedTaskStatus,
|
|
55
|
+
from adcp.types.generated import TaskStatus as GeneratedTaskStatus
|
|
56
|
+
from adcp.validation import (
|
|
57
|
+
ValidationError,
|
|
58
|
+
validate_adagents,
|
|
59
|
+
validate_agent_authorization,
|
|
60
|
+
validate_product,
|
|
61
|
+
validate_publisher_properties_item,
|
|
164
62
|
)
|
|
165
63
|
|
|
166
|
-
__version__ = "
|
|
64
|
+
__version__ = "2.0.0"
|
|
167
65
|
|
|
168
66
|
__all__ = [
|
|
169
67
|
# Client classes
|
|
@@ -210,113 +108,13 @@ __all__ = [
|
|
|
210
108
|
"AdagentsValidationError",
|
|
211
109
|
"AdagentsNotFoundError",
|
|
212
110
|
"AdagentsTimeoutError",
|
|
213
|
-
#
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
"
|
|
219
|
-
|
|
220
|
-
"
|
|
221
|
-
"BuildCreativeRequest",
|
|
222
|
-
"BuildCreativeResponse",
|
|
223
|
-
"CreateMediaBuyRequest",
|
|
224
|
-
"CreateMediaBuyResponse",
|
|
225
|
-
"CreateMediaBuySuccess",
|
|
226
|
-
"CreateMediaBuyError",
|
|
227
|
-
"GetMediaBuyDeliveryRequest",
|
|
228
|
-
"GetMediaBuyDeliveryResponse",
|
|
229
|
-
"GetProductsRequest",
|
|
230
|
-
"GetProductsResponse",
|
|
231
|
-
"GetSignalsRequest",
|
|
232
|
-
"GetSignalsResponse",
|
|
233
|
-
"ListAuthorizedPropertiesRequest",
|
|
234
|
-
"ListAuthorizedPropertiesResponse",
|
|
235
|
-
"ListCreativeFormatsRequest",
|
|
236
|
-
"ListCreativeFormatsResponse",
|
|
237
|
-
"ListCreativesRequest",
|
|
238
|
-
"ListCreativesResponse",
|
|
239
|
-
"PreviewCreativeRequest",
|
|
240
|
-
"PreviewCreativeResponse",
|
|
241
|
-
"ProvidePerformanceFeedbackRequest",
|
|
242
|
-
"ProvidePerformanceFeedbackResponse",
|
|
243
|
-
"SyncCreativesRequest",
|
|
244
|
-
"SyncCreativesResponse",
|
|
245
|
-
"SyncCreativesSuccess",
|
|
246
|
-
"SyncCreativesError",
|
|
247
|
-
"UpdateMediaBuyRequest",
|
|
248
|
-
"UpdateMediaBuyResponse",
|
|
249
|
-
"UpdateMediaBuySuccess",
|
|
250
|
-
"UpdateMediaBuyError",
|
|
251
|
-
# Core domain types
|
|
252
|
-
"MediaBuy",
|
|
253
|
-
"Product",
|
|
254
|
-
"Package",
|
|
255
|
-
"Error",
|
|
256
|
-
# Creative types
|
|
257
|
-
"CreativeAsset",
|
|
258
|
-
"CreativeManifest",
|
|
259
|
-
"CreativeAssignment",
|
|
260
|
-
"CreativePolicy",
|
|
261
|
-
"Format",
|
|
262
|
-
"FormatId",
|
|
263
|
-
# Property and placement types
|
|
264
|
-
"Property",
|
|
265
|
-
"Placement",
|
|
266
|
-
# Targeting types
|
|
267
|
-
"Targeting",
|
|
268
|
-
"FrequencyCap",
|
|
269
|
-
"Pacing",
|
|
270
|
-
# Brand types
|
|
271
|
-
"BrandManifest",
|
|
272
|
-
"BrandManifestRef",
|
|
273
|
-
# Metrics types
|
|
274
|
-
"DeliveryMetrics",
|
|
275
|
-
"Measurement",
|
|
276
|
-
"PerformanceFeedback",
|
|
277
|
-
# Status enums
|
|
278
|
-
"MediaBuyStatus",
|
|
279
|
-
"PackageStatus",
|
|
280
|
-
# Pricing types
|
|
281
|
-
"PricingOption",
|
|
282
|
-
"PricingModel",
|
|
283
|
-
# Delivery types
|
|
284
|
-
"DeliveryType",
|
|
285
|
-
"StartTiming",
|
|
286
|
-
# Channel types
|
|
287
|
-
"Channels",
|
|
288
|
-
"StandardFormatIds",
|
|
289
|
-
# Protocol types
|
|
290
|
-
"WebhookPayload",
|
|
291
|
-
"ProtocolEnvelope",
|
|
292
|
-
"Response",
|
|
293
|
-
"PromotedProducts",
|
|
294
|
-
"PushNotificationConfig",
|
|
295
|
-
"ReportingCapabilities",
|
|
296
|
-
# Deployment types
|
|
297
|
-
"Destination",
|
|
298
|
-
"Deployment",
|
|
299
|
-
"PlatformDestination",
|
|
300
|
-
"AgentDestination",
|
|
301
|
-
"PlatformDeployment",
|
|
302
|
-
"AgentDeployment",
|
|
303
|
-
# Sub-asset types
|
|
304
|
-
"MediaSubAsset",
|
|
305
|
-
"SubAsset",
|
|
306
|
-
"TextSubAsset",
|
|
307
|
-
# Asset delivery types (VAST/DAAST)
|
|
308
|
-
"VastAsset",
|
|
309
|
-
"UrlVastAsset",
|
|
310
|
-
"InlineVastAsset",
|
|
311
|
-
"DaastAsset",
|
|
312
|
-
"UrlDaastAsset",
|
|
313
|
-
"InlineDaastAsset",
|
|
314
|
-
# Preview render types
|
|
315
|
-
"PreviewRender",
|
|
316
|
-
"UrlPreviewRender",
|
|
317
|
-
"HtmlPreviewRender",
|
|
318
|
-
"BothPreviewRender",
|
|
319
|
-
# Task types
|
|
320
|
-
"TaskType",
|
|
111
|
+
# Validation utilities
|
|
112
|
+
"ValidationError",
|
|
113
|
+
"validate_adagents",
|
|
114
|
+
"validate_agent_authorization",
|
|
115
|
+
"validate_product",
|
|
116
|
+
"validate_publisher_properties_item",
|
|
117
|
+
# Generated types module
|
|
118
|
+
"generated",
|
|
321
119
|
"GeneratedTaskStatus",
|
|
322
120
|
]
|
adcp/adagents.py
CHANGED
|
@@ -14,6 +14,7 @@ from urllib.parse import urlparse
|
|
|
14
14
|
import httpx
|
|
15
15
|
|
|
16
16
|
from adcp.exceptions import AdagentsNotFoundError, AdagentsTimeoutError, AdagentsValidationError
|
|
17
|
+
from adcp.validation import ValidationError, validate_adagents
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def _normalize_domain(domain: str) -> str:
|
|
@@ -56,9 +57,7 @@ def _validate_publisher_domain(domain: str) -> str:
|
|
|
56
57
|
suspicious_chars = ["\\", "@", "\n", "\r", "\t"]
|
|
57
58
|
for char in suspicious_chars:
|
|
58
59
|
if char in domain:
|
|
59
|
-
raise AdagentsValidationError(
|
|
60
|
-
f"Invalid character in publisher domain: {char!r}"
|
|
61
|
-
)
|
|
60
|
+
raise AdagentsValidationError(f"Invalid character in publisher domain: {char!r}")
|
|
62
61
|
|
|
63
62
|
domain = domain.strip()
|
|
64
63
|
|
|
@@ -70,9 +69,7 @@ def _validate_publisher_domain(domain: str) -> str:
|
|
|
70
69
|
|
|
71
70
|
# Check for spaces after stripping leading/trailing whitespace
|
|
72
71
|
if " " in domain:
|
|
73
|
-
raise AdagentsValidationError(
|
|
74
|
-
"Invalid character in publisher domain: ' '"
|
|
75
|
-
)
|
|
72
|
+
raise AdagentsValidationError("Invalid character in publisher domain: ' '")
|
|
76
73
|
|
|
77
74
|
# Remove protocol if present (common user error) - do this BEFORE checking for slashes
|
|
78
75
|
if "://" in domain:
|
|
@@ -87,9 +84,7 @@ def _validate_publisher_domain(domain: str) -> str:
|
|
|
87
84
|
|
|
88
85
|
# Final validation - must look like a domain
|
|
89
86
|
if "." not in domain:
|
|
90
|
-
raise AdagentsValidationError(
|
|
91
|
-
f"Publisher domain must contain at least one dot: {domain!r}"
|
|
92
|
-
)
|
|
87
|
+
raise AdagentsValidationError(f"Publisher domain must contain at least one dot: {domain!r}")
|
|
93
88
|
|
|
94
89
|
return domain
|
|
95
90
|
|
|
@@ -359,13 +354,17 @@ async def fetch_adagents(
|
|
|
359
354
|
raise AdagentsValidationError("adagents.json must be a JSON object")
|
|
360
355
|
|
|
361
356
|
if "authorized_agents" not in data:
|
|
362
|
-
raise AdagentsValidationError(
|
|
363
|
-
"adagents.json must have 'authorized_agents' field"
|
|
364
|
-
)
|
|
357
|
+
raise AdagentsValidationError("adagents.json must have 'authorized_agents' field")
|
|
365
358
|
|
|
366
359
|
if not isinstance(data["authorized_agents"], list):
|
|
367
360
|
raise AdagentsValidationError("'authorized_agents' must be an array")
|
|
368
361
|
|
|
362
|
+
# Validate mutual exclusivity constraints
|
|
363
|
+
try:
|
|
364
|
+
validate_adagents(data)
|
|
365
|
+
except ValidationError as e:
|
|
366
|
+
raise AdagentsValidationError(f"Invalid adagents.json structure: {e}") from e
|
|
367
|
+
|
|
369
368
|
return data
|
|
370
369
|
|
|
371
370
|
except httpx.TimeoutException as e:
|
adcp/client.py
CHANGED
|
@@ -23,6 +23,7 @@ from adcp.types.core import (
|
|
|
23
23
|
AgentConfig,
|
|
24
24
|
Protocol,
|
|
25
25
|
TaskResult,
|
|
26
|
+
TaskStatus,
|
|
26
27
|
)
|
|
27
28
|
from adcp.types.generated import (
|
|
28
29
|
ActivateSignalRequest,
|
|
@@ -47,6 +48,7 @@ from adcp.types.generated import (
|
|
|
47
48
|
SyncCreativesResponse,
|
|
48
49
|
WebhookPayload,
|
|
49
50
|
)
|
|
51
|
+
from adcp.types.generated_poc.task_status import TaskStatus as GeneratedTaskStatus
|
|
50
52
|
from adcp.utils.operation_id import create_operation_id
|
|
51
53
|
|
|
52
54
|
logger = logging.getLogger(__name__)
|
|
@@ -624,7 +626,6 @@ class ADCPClient:
|
|
|
624
626
|
Returns:
|
|
625
627
|
TaskResult with task-specific typed response data
|
|
626
628
|
"""
|
|
627
|
-
from adcp.types.core import TaskStatus
|
|
628
629
|
from adcp.utils.response_parser import parse_json_or_text
|
|
629
630
|
|
|
630
631
|
# Map task types to their response types (using string literals, not enum)
|
|
@@ -643,8 +644,8 @@ class ADCPClient:
|
|
|
643
644
|
|
|
644
645
|
# Handle completed tasks with result parsing
|
|
645
646
|
|
|
646
|
-
if webhook.status ==
|
|
647
|
-
response_type = response_type_map.get(webhook.task_type)
|
|
647
|
+
if webhook.status == GeneratedTaskStatus.completed and webhook.result is not None:
|
|
648
|
+
response_type = response_type_map.get(webhook.task_type.value)
|
|
648
649
|
if response_type:
|
|
649
650
|
try:
|
|
650
651
|
parsed_result: Any = parse_json_or_text(webhook.result, response_type)
|
|
@@ -664,17 +665,21 @@ class ADCPClient:
|
|
|
664
665
|
# Fall through to untyped result
|
|
665
666
|
|
|
666
667
|
# Handle failed, input-required, or unparseable results
|
|
667
|
-
# Convert webhook status
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
668
|
+
# Convert webhook status to core TaskStatus enum
|
|
669
|
+
# Map generated enum values to core enum values
|
|
670
|
+
status_map = {
|
|
671
|
+
GeneratedTaskStatus.completed: TaskStatus.COMPLETED,
|
|
672
|
+
GeneratedTaskStatus.submitted: TaskStatus.SUBMITTED,
|
|
673
|
+
GeneratedTaskStatus.working: TaskStatus.WORKING,
|
|
674
|
+
GeneratedTaskStatus.failed: TaskStatus.FAILED,
|
|
675
|
+
GeneratedTaskStatus.input_required: TaskStatus.NEEDS_INPUT,
|
|
676
|
+
}
|
|
677
|
+
task_status = status_map.get(webhook.status, TaskStatus.FAILED)
|
|
673
678
|
|
|
674
679
|
return TaskResult[Any](
|
|
675
680
|
status=task_status,
|
|
676
681
|
data=webhook.result,
|
|
677
|
-
success=webhook.status ==
|
|
682
|
+
success=webhook.status == GeneratedTaskStatus.completed,
|
|
678
683
|
error=webhook.error if isinstance(webhook.error, str) else None,
|
|
679
684
|
metadata={
|
|
680
685
|
"task_id": webhook.task_id,
|
|
@@ -732,7 +737,7 @@ class ADCPClient:
|
|
|
732
737
|
type=ActivityType.WEBHOOK_RECEIVED,
|
|
733
738
|
operation_id=webhook.operation_id or "unknown",
|
|
734
739
|
agent_id=self.agent_config.id,
|
|
735
|
-
task_type=webhook.task_type,
|
|
740
|
+
task_type=webhook.task_type.value,
|
|
736
741
|
timestamp=datetime.now(timezone.utc).isoformat(),
|
|
737
742
|
metadata={"payload": payload},
|
|
738
743
|
)
|